Documentation ¶
Overview ¶
Package kmsiface provides an interface to enable mocking the AWS Key Management Service service client for testing your code.
It is important to note that this interface will have breaking changes when the service model is updated and adds new API operations, paginators, and waiters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KMSAPI ¶
type KMSAPI interface { CancelKeyDeletionRequest(*kms.CancelKeyDeletionInput) (*request.Request, *kms.CancelKeyDeletionOutput) CancelKeyDeletion(*kms.CancelKeyDeletionInput) (*kms.CancelKeyDeletionOutput, error) CreateAliasRequest(*kms.CreateAliasInput) (*request.Request, *kms.CreateAliasOutput) CreateAlias(*kms.CreateAliasInput) (*kms.CreateAliasOutput, error) CreateGrantRequest(*kms.CreateGrantInput) (*request.Request, *kms.CreateGrantOutput) CreateGrant(*kms.CreateGrantInput) (*kms.CreateGrantOutput, error) CreateKeyRequest(*kms.CreateKeyInput) (*request.Request, *kms.CreateKeyOutput) CreateKey(*kms.CreateKeyInput) (*kms.CreateKeyOutput, error) DecryptRequest(*kms.DecryptInput) (*request.Request, *kms.DecryptOutput) Decrypt(*kms.DecryptInput) (*kms.DecryptOutput, error) DeleteAliasRequest(*kms.DeleteAliasInput) (*request.Request, *kms.DeleteAliasOutput) DeleteAlias(*kms.DeleteAliasInput) (*kms.DeleteAliasOutput, error) DeleteImportedKeyMaterialRequest(*kms.DeleteImportedKeyMaterialInput) (*request.Request, *kms.DeleteImportedKeyMaterialOutput) DeleteImportedKeyMaterial(*kms.DeleteImportedKeyMaterialInput) (*kms.DeleteImportedKeyMaterialOutput, error) DescribeKeyRequest(*kms.DescribeKeyInput) (*request.Request, *kms.DescribeKeyOutput) DescribeKey(*kms.DescribeKeyInput) (*kms.DescribeKeyOutput, error) DisableKeyRequest(*kms.DisableKeyInput) (*request.Request, *kms.DisableKeyOutput) DisableKey(*kms.DisableKeyInput) (*kms.DisableKeyOutput, error) DisableKeyRotationRequest(*kms.DisableKeyRotationInput) (*request.Request, *kms.DisableKeyRotationOutput) DisableKeyRotation(*kms.DisableKeyRotationInput) (*kms.DisableKeyRotationOutput, error) EnableKeyRequest(*kms.EnableKeyInput) (*request.Request, *kms.EnableKeyOutput) EnableKey(*kms.EnableKeyInput) (*kms.EnableKeyOutput, error) EnableKeyRotationRequest(*kms.EnableKeyRotationInput) (*request.Request, *kms.EnableKeyRotationOutput) EnableKeyRotation(*kms.EnableKeyRotationInput) (*kms.EnableKeyRotationOutput, error) EncryptRequest(*kms.EncryptInput) (*request.Request, *kms.EncryptOutput) Encrypt(*kms.EncryptInput) (*kms.EncryptOutput, error) GenerateDataKeyRequest(*kms.GenerateDataKeyInput) (*request.Request, *kms.GenerateDataKeyOutput) GenerateDataKey(*kms.GenerateDataKeyInput) (*kms.GenerateDataKeyOutput, error) GenerateDataKeyWithoutPlaintextRequest(*kms.GenerateDataKeyWithoutPlaintextInput) (*request.Request, *kms.GenerateDataKeyWithoutPlaintextOutput) GenerateDataKeyWithoutPlaintext(*kms.GenerateDataKeyWithoutPlaintextInput) (*kms.GenerateDataKeyWithoutPlaintextOutput, error) GenerateRandomRequest(*kms.GenerateRandomInput) (*request.Request, *kms.GenerateRandomOutput) GenerateRandom(*kms.GenerateRandomInput) (*kms.GenerateRandomOutput, error) GetKeyPolicyRequest(*kms.GetKeyPolicyInput) (*request.Request, *kms.GetKeyPolicyOutput) GetKeyPolicy(*kms.GetKeyPolicyInput) (*kms.GetKeyPolicyOutput, error) GetKeyRotationStatusRequest(*kms.GetKeyRotationStatusInput) (*request.Request, *kms.GetKeyRotationStatusOutput) GetKeyRotationStatus(*kms.GetKeyRotationStatusInput) (*kms.GetKeyRotationStatusOutput, error) GetParametersForImportRequest(*kms.GetParametersForImportInput) (*request.Request, *kms.GetParametersForImportOutput) GetParametersForImport(*kms.GetParametersForImportInput) (*kms.GetParametersForImportOutput, error) ImportKeyMaterialRequest(*kms.ImportKeyMaterialInput) (*request.Request, *kms.ImportKeyMaterialOutput) ImportKeyMaterial(*kms.ImportKeyMaterialInput) (*kms.ImportKeyMaterialOutput, error) ListAliasesRequest(*kms.ListAliasesInput) (*request.Request, *kms.ListAliasesOutput) ListAliases(*kms.ListAliasesInput) (*kms.ListAliasesOutput, error) ListAliasesPages(*kms.ListAliasesInput, func(*kms.ListAliasesOutput, bool) bool) error ListGrantsRequest(*kms.ListGrantsInput) (*request.Request, *kms.ListGrantsResponse) ListGrants(*kms.ListGrantsInput) (*kms.ListGrantsResponse, error) ListGrantsPages(*kms.ListGrantsInput, func(*kms.ListGrantsResponse, bool) bool) error ListKeyPoliciesRequest(*kms.ListKeyPoliciesInput) (*request.Request, *kms.ListKeyPoliciesOutput) ListKeyPolicies(*kms.ListKeyPoliciesInput) (*kms.ListKeyPoliciesOutput, error) ListKeyPoliciesPages(*kms.ListKeyPoliciesInput, func(*kms.ListKeyPoliciesOutput, bool) bool) error ListKeysRequest(*kms.ListKeysInput) (*request.Request, *kms.ListKeysOutput) ListKeys(*kms.ListKeysInput) (*kms.ListKeysOutput, error) ListKeysPages(*kms.ListKeysInput, func(*kms.ListKeysOutput, bool) bool) error ListResourceTagsRequest(*kms.ListResourceTagsInput) (*request.Request, *kms.ListResourceTagsOutput) ListResourceTags(*kms.ListResourceTagsInput) (*kms.ListResourceTagsOutput, error) ListRetirableGrantsRequest(*kms.ListRetirableGrantsInput) (*request.Request, *kms.ListGrantsResponse) ListRetirableGrants(*kms.ListRetirableGrantsInput) (*kms.ListGrantsResponse, error) PutKeyPolicyRequest(*kms.PutKeyPolicyInput) (*request.Request, *kms.PutKeyPolicyOutput) PutKeyPolicy(*kms.PutKeyPolicyInput) (*kms.PutKeyPolicyOutput, error) ReEncryptRequest(*kms.ReEncryptInput) (*request.Request, *kms.ReEncryptOutput) ReEncrypt(*kms.ReEncryptInput) (*kms.ReEncryptOutput, error) RetireGrantRequest(*kms.RetireGrantInput) (*request.Request, *kms.RetireGrantOutput) RetireGrant(*kms.RetireGrantInput) (*kms.RetireGrantOutput, error) RevokeGrantRequest(*kms.RevokeGrantInput) (*request.Request, *kms.RevokeGrantOutput) RevokeGrant(*kms.RevokeGrantInput) (*kms.RevokeGrantOutput, error) ScheduleKeyDeletionRequest(*kms.ScheduleKeyDeletionInput) (*request.Request, *kms.ScheduleKeyDeletionOutput) ScheduleKeyDeletion(*kms.ScheduleKeyDeletionInput) (*kms.ScheduleKeyDeletionOutput, error) TagResourceRequest(*kms.TagResourceInput) (*request.Request, *kms.TagResourceOutput) TagResource(*kms.TagResourceInput) (*kms.TagResourceOutput, error) UntagResourceRequest(*kms.UntagResourceInput) (*request.Request, *kms.UntagResourceOutput) UntagResource(*kms.UntagResourceInput) (*kms.UntagResourceOutput, error) UpdateAliasRequest(*kms.UpdateAliasInput) (*request.Request, *kms.UpdateAliasOutput) UpdateAlias(*kms.UpdateAliasInput) (*kms.UpdateAliasOutput, error) UpdateKeyDescriptionRequest(*kms.UpdateKeyDescriptionInput) (*request.Request, *kms.UpdateKeyDescriptionOutput) UpdateKeyDescription(*kms.UpdateKeyDescriptionInput) (*kms.UpdateKeyDescriptionOutput, error) }
KMSAPI provides an interface to enable mocking the kms.KMS service client's API operation, paginators, and waiters. This make unit testing your code that calls out to the SDK's service client's calls easier.
The best way to use this interface is so the SDK's service client's calls can be stubbed out for unit testing your code with the SDK without needing to inject custom request handlers into the the SDK's request pipeline.
// myFunc uses an SDK service client to make a request to // AWS Key Management Service. func myFunc(svc kmsiface.KMSAPI) bool { // Make svc.CancelKeyDeletion request } func main() { sess := session.New() svc := kms.New(sess) myFunc(svc) }
In your _test.go file:
// Define a mock struct to be used in your unit tests of myFunc. type mockKMSClient struct { kmsiface.KMSAPI } func (m *mockKMSClient) CancelKeyDeletion(input *kms.CancelKeyDeletionInput) (*kms.CancelKeyDeletionOutput, error) { // mock response/functionality } TestMyFunc(t *testing.T) { // Setup Test mockSvc := &mockKMSClient{} myfunc(mockSvc) // Verify myFunc's functionality }
It is important to note that this interface will have breaking changes when the service model is updated and adds new API operations, paginators, and waiters. Its suggested to use the pattern above for testing, or using tooling to generate mocks to satisfy the interfaces.