本文整理匯總了Golang中github.com/docker/swarmkit/ca.DefaultAcceptancePolicy函數的典型用法代碼示例。如果您正苦於以下問題:Golang DefaultAcceptancePolicy函數的具體用法?Golang DefaultAcceptancePolicy怎麽用?Golang DefaultAcceptancePolicy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DefaultAcceptancePolicy函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestGetRemoteSignedCertificateWithPending
func TestGetRemoteSignedCertificateWithPending(t *testing.T) {
tc := testutils.NewTestCA(t, ca.DefaultAcceptancePolicy())
defer tc.Stop()
// Create a new CSR to be signed
csr, _, err := ca.GenerateAndWriteNewKey(tc.Paths.Node)
assert.NoError(t, err)
updates, cancel := state.Watch(tc.MemoryStore.WatchQueue(), state.EventCreateNode{})
defer cancel()
completed := make(chan error)
go func() {
_, err := ca.GetRemoteSignedCertificate(context.Background(), csr, ca.ManagerRole, "", tc.RootCA.Pool, tc.Picker, nil, nil)
completed <- err
}()
event := <-updates
node := event.(state.EventCreateNode).Node.Copy()
// Directly update the status of the store
err = tc.MemoryStore.Update(func(tx store.Tx) error {
node.Certificate.Status.State = api.IssuanceStateIssued
return store.UpdateNode(tx, node)
})
assert.NoError(t, err)
// Make sure GetRemoteSignedCertificate didn't return an error
assert.NoError(t, <-completed)
}
示例2: TestRestartRootCA
func TestRestartRootCA(t *testing.T) {
tc := testutils.NewTestCA(t, ca.DefaultAcceptancePolicy())
defer tc.Stop()
resp1, err := tc.CAClients[0].GetRootCACertificate(context.Background(), &api.GetRootCACertificateRequest{})
assert.NoError(t, err)
assert.NotEmpty(t, resp1.Certificate)
tc.CAServer.Stop()
go tc.CAServer.Run(context.Background())
resp2, err := tc.CAClients[0].GetRootCACertificate(context.Background(), &api.GetRootCACertificateRequest{})
assert.NoError(t, err)
assert.Equal(t, resp1.Certificate, resp2.Certificate)
}
示例3: TestIssueNodeCertificateWithInvalidCSR
func TestIssueNodeCertificateWithInvalidCSR(t *testing.T) {
tc := testutils.NewTestCA(t, ca.DefaultAcceptancePolicy())
defer tc.Stop()
role := api.NodeRoleWorker
issueRequest := &api.IssueNodeCertificateRequest{CSR: []byte("random garbage"), Role: role}
issueResponse, err := tc.NodeCAClients[0].IssueNodeCertificate(context.Background(), issueRequest)
assert.NoError(t, err)
assert.NotNil(t, issueResponse.NodeID)
assert.Equal(t, api.NodeMembershipAccepted, issueResponse.NodeMembership)
statusRequest := &api.NodeCertificateStatusRequest{NodeID: issueResponse.NodeID}
statusResponse, err := tc.NodeCAClients[0].NodeCertificateStatus(context.Background(), statusRequest)
assert.Equal(t, api.IssuanceStateFailed, statusResponse.Status.State)
assert.Contains(t, statusResponse.Status.Err, "CSR Decode failed")
assert.Nil(t, statusResponse.Certificate.Certificate)
}
示例4: TestIssueNodeCertificateManagerRenewal
func TestIssueNodeCertificateManagerRenewal(t *testing.T) {
tc := testutils.NewTestCA(t, ca.DefaultAcceptancePolicy())
defer tc.Stop()
csr, _, err := ca.GenerateAndWriteNewKey(tc.Paths.Node)
assert.NoError(t, err)
assert.NotNil(t, csr)
role := api.NodeRoleManager
issueRequest := &api.IssueNodeCertificateRequest{CSR: csr, Role: role}
issueResponse, err := tc.NodeCAClients[2].IssueNodeCertificate(context.Background(), issueRequest)
assert.NotNil(t, issueResponse.NodeID)
assert.Equal(t, api.NodeMembershipAccepted, issueResponse.NodeMembership)
statusRequest := &api.NodeCertificateStatusRequest{NodeID: issueResponse.NodeID}
statusResponse, err := tc.NodeCAClients[2].NodeCertificateStatus(context.Background(), statusRequest)
assert.Equal(t, api.IssuanceStateIssued, statusResponse.Status.State)
assert.NotNil(t, statusResponse.Certificate.Certificate)
assert.Equal(t, role, statusResponse.Certificate.Role)
}