java - 单元测试 AWS 秘密管理器 java
问题描述
我需要对 Java 中的 AWS 秘密管理器进行单元测试,并且正在使用 Mockito 和 EasyMock 来执行此操作,并且每当我调用 client.getSecretValue() 时,它都会抛出 要测试的异常代码
AWSSecretsManagerClient client =
(AWSSecretsManagerClient)
AWSSecretsManagerClientBuilder.standard().withRegion(region).build();
String secret = null, decodedBinarySecret = null;
GetSecretValueRequest getSecretValueRequest = new GetSecretValueRequest().withSecretId(secretName);
GetSecretValueResult getSecretValueResult = null;
AWSSecrets awsSecrets = null;
try {
getSecretValueResult = client.getSecretValue(getSecretValueRequest);
} catch (DecryptionFailureException e) {
例外
"com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain: [EnvironmentVariableCredentialsProvider: Unable to load AWS credentials from environment variables (AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY) and AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)), SystemPropertiesCredentialsProvider: Unable to load AWS credentials from Java system properties (aws.accessKeyId and aws.secretKey), com.amazonaws.auth.profile.ProfileCredentialsProvider@28ce75ec: Unable to load credentials into profile [default]: AWS Access Key ID is not specified., WebIdentityTokenCredentialsProvider: To use assume role profiles the aws-java-sdk-sts module must be on the class path., com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@4db728df: Unable to load credentials from service endpoint]".
有人可以帮我吗?
解决方案
推荐阅读
- c# - 使用 htmlagilitypack 选择特定的 td
- laravel - Laravel 错误:调用字符串上的成员函数 format()
- elasticsearch - 判断elasticsearch恢复失败
- ms-access - MS Access 组合框显示选项卡
- html - SVG 光标有不需要的灰色边缘
- android - 将 ImageButton 放在两个视图组之间
- amazon-web-services - 权限有助于设置用户对 S3 的访问权限
- javascript - IIFE:如果我返回警报而不将其包装在函数中,为什么我的代码会忽略 addEventListener?
- keras - 使用 Keras 添加和访问辅助 tf.Dataset 属性
- java - Java 流操作调用