diff --git a/src/AWSConfig.jl b/src/AWSConfig.jl index b050608d0..d7aa9630c 100644 --- a/src/AWSConfig.jl +++ b/src/AWSConfig.jl @@ -54,9 +54,7 @@ function aws_account_number(aws::AWSConfig) end function _update_creds!(aws_config::AWSConfig) - r = AWSServices.sts( - "GetCallerIdentity"; aws_config=aws_config, features=DEFAULT_SERVICE_FEATURES - ) + r = AWSServices.sts("GetCallerIdentity"; aws_config=aws_config) r = r["GetCallerIdentityResult"] creds = aws_config.credentials diff --git a/src/AWSCredentials.jl b/src/AWSCredentials.jl index bbffd3724..53f13248f 100644 --- a/src/AWSCredentials.jl +++ b/src/AWSCredentials.jl @@ -287,10 +287,7 @@ function ec2_instance_credentials(profile::AbstractString) params["DurationSeconds"] = parse(Int, duration) end resp = @mock AWSServices.sts( - "AssumeRole", - params; - aws_config=AWSConfig(; creds=instance_profile_creds), - features=DEFAULT_SERVICE_FEATURES, + "AssumeRole", params; aws_config=AWSConfig(; creds=instance_profile_creds) ) role_creds = resp["AssumeRoleResult"]["Credentials"] role_user = resp["AssumeRoleResult"]["AssumedRoleUser"] @@ -522,7 +519,6 @@ function credentials_from_webtoken() "WebIdentityToken" => web_identity, ); aws_config=AWSConfig(; creds=nothing), - features=DEFAULT_SERVICE_FEATURES, ) role_creds = resp["AssumeRoleWithWebIdentityResult"]["Credentials"] diff --git a/src/utilities/credentials.jl b/src/utilities/credentials.jl index 0898faaf0..bfc056175 100644 --- a/src/utilities/credentials.jl +++ b/src/utilities/credentials.jl @@ -93,9 +93,7 @@ function _aws_get_role(role::AbstractString, ini::Inifile) # RoleSessionName Documentation # https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html - role = @mock AWSServices.sts( - "AssumeRole", params; aws_config=config, features=DEFAULT_SERVICE_FEATURES - ) + role = @mock AWSServices.sts("AssumeRole", params; aws_config=config) role_creds = role["AssumeRoleResult"]["Credentials"] diff --git a/test/AWS.jl b/test/AWS.jl index aa766cf52..588faa095 100644 --- a/test/AWS.jl +++ b/test/AWS.jl @@ -553,7 +553,7 @@ end end @testset "low-level" begin - response = AWSServices.sts("GetCallerIdentity"; LOW_LVL_KWARGS...) + response = AWSServices.sts("GetCallerIdentity") d = response["GetCallerIdentityResult"] @test Set(keys(d)) == Set(["Arn", "UserId", "Account"]) @@ -599,7 +599,7 @@ end function _get_secret_string(secret_name) response = AWSServices.secrets_manager( - "GetSecretValue", LittleDict("SecretId" => secret_name); LOW_LVL_KWARGS... + "GetSecretValue", LittleDict("SecretId" => secret_name) ) return response["SecretString"] @@ -611,8 +611,7 @@ end "Name" => secret_name, "SecretString" => secret_string, "ClientRequestToken" => string(uuid4()), - ); - LOW_LVL_KWARGS..., + ), ) try @@ -622,8 +621,7 @@ end "DeleteSecret", LittleDict( "SecretId" => secret_name, "ForceDeleteWithoutRecovery" => "true" - ); - LOW_LVL_KWARGS..., + ), ) end @@ -683,27 +681,23 @@ end LittleDict( "PolicyName" => expected_policy_name, "PolicyDocument" => expected_policy_document, - ); - LOW_LVL_KWARGS..., + ), ) policy_arn = response["CreatePolicyResult"]["Policy"]["Arn"] try response_policy_version = AWSServices.iam( "GetPolicyVersion", - LittleDict("PolicyArn" => policy_arn, "VersionId" => "v1"); - LOW_LVL_KWARGS..., + LittleDict("PolicyArn" => policy_arn, "VersionId" => "v1"), ) response_document = response_policy_version["GetPolicyVersionResult"]["PolicyVersion"]["Document"] @test HTTP.unescapeuri(response_document) == expected_policy_document finally - AWSServices.iam( - "DeletePolicy", LittleDict("PolicyArn" => policy_arn); LOW_LVL_KWARGS... - ) + AWSServices.iam("DeletePolicy", LittleDict("PolicyArn" => policy_arn)) end @test_throws AWSException AWSServices.iam( - "GetPolicy", LittleDict("PolicyArn" => policy_arn); LOW_LVL_KWARGS... + "GetPolicy", LittleDict("PolicyArn" => policy_arn) ) end @@ -764,17 +758,13 @@ end expected_message = "Hello for AWS.jl" function _get_queue_url(queue_name) - result = AWSServices.sqs( - "GetQueueUrl", LittleDict("QueueName" => queue_name); LOW_LVL_KWARGS... - ) + result = AWSServices.sqs("GetQueueUrl", LittleDict("QueueName" => queue_name)) return result["GetQueueUrlResult"]["QueueUrl"] end # Create Queue - AWSServices.sqs( - "CreateQueue", LittleDict("QueueName" => queue_name); LOW_LVL_KWARGS... - ) + AWSServices.sqs("CreateQueue", LittleDict("QueueName" => queue_name)) queue_url = _get_queue_url(queue_name) @test !isempty(queue_url) @@ -785,12 +775,11 @@ end AWSServices.sqs( "SendMessage", - LittleDict("QueueUrl" => queue_url, "MessageBody" => expected_message); - LOW_LVL_KWARGS..., + LittleDict("QueueUrl" => queue_url, "MessageBody" => expected_message), ) response = AWSServices.sqs( - "ReceiveMessage", LittleDict("QueueUrl" => queue_url); LOW_LVL_KWARGS... + "ReceiveMessage", LittleDict("QueueUrl" => queue_url) ) receipt_handle = response["ReceiveMessageResult"]["Message"]["ReceiptHandle"] @@ -804,8 +793,7 @@ end "ReceiptHandle" => receipt_handle, ), ], - ); - LOW_LVL_KWARGS..., + ), ) message_id = response["DeleteMessageBatchResult"]["DeleteMessageBatchResultEntry"]["Id"] @@ -814,20 +802,15 @@ end # Send message AWSServices.sqs( "SendMessage", - LittleDict("QueueUrl" => queue_url, "MessageBody" => expected_message); - LOW_LVL_KWARGS..., + LittleDict("QueueUrl" => queue_url, "MessageBody" => expected_message), ) # Receive Message - result = AWSServices.sqs( - "ReceiveMessage", LittleDict("QueueUrl" => queue_url); LOW_LVL_KWARGS... - ) + result = AWSServices.sqs("ReceiveMessage", LittleDict("QueueUrl" => queue_url)) message = result["ReceiveMessageResult"]["Message"]["Body"] @test message == expected_message finally - AWSServices.sqs( - "DeleteQueue", LittleDict("QueueUrl" => queue_url); LOW_LVL_KWARGS... - ) + AWSServices.sqs("DeleteQueue", LittleDict("QueueUrl" => queue_url)) end @test_throws AWSException _get_queue_url(queue_name) @@ -902,7 +885,7 @@ end function _bucket_exists(bucket_name) try - AWSServices.s3("HEAD", "/$bucket_name"; LOW_LVL_KWARGS...) + AWSServices.s3("HEAD", "/$bucket_name") return true catch e if e isa AWSException && e.cause.status == 404 @@ -917,28 +900,22 @@ end @test _bucket_exists(bucket_name) == false # PUT operation - AWSServices.s3("PUT", "/$bucket_name"; LOW_LVL_KWARGS...) + AWSServices.s3("PUT", "/$bucket_name") @test _bucket_exists(bucket_name) try # PUT with parameters operation body = Array{UInt8}("sample-file-body") - AWSServices.s3( - "PUT", "/$bucket_name/$file_name", Dict("body" => body); LOW_LVL_KWARGS... - ) - @test AWSServices.s3( - "GET", "/$bucket_name/$file_name"; LOW_LVL_KWARGS... - ).body == body + AWSServices.s3("PUT", "/$bucket_name/$file_name", Dict("body" => body)) + @test AWSServices.s3("GET", "/$bucket_name/$file_name") == body # GET operation - result = AWSServices.s3("GET", "/$bucket_name"; LOW_LVL_KWARGS...) + result = AWSServices.s3("GET", "/$bucket_name") @test result["Contents"]["Key"] == file_name # GET with parameters operation max_keys = 1 - result = AWSServices.s3( - "GET", "/$bucket_name", Dict("max_keys" => max_keys); LOW_LVL_KWARGS... - ) + result = AWSServices.s3("GET", "/$bucket_name", Dict("max_keys" => max_keys)) @test length([result["Contents"]]) == max_keys # POST with parameters operation @@ -950,15 +927,11 @@ end """ - AWSServices.s3( - "POST", "/$bucket_name?delete", Dict("body" => body); LOW_LVL_KWARGS... - ) - @test_throws AWSException AWSServices.s3( - "GET", "/$bucket_name/$file_name"; LOW_LVL_KWARGS... - ) + AWSServices.s3("POST", "/$bucket_name?delete", Dict("body" => body)) + @test_throws AWSException AWSServices.s3("GET", "/$bucket_name/$file_name") finally # DELETE operation - AWSServices.s3("DELETE", "/$bucket_name"; LOW_LVL_KWARGS...) + AWSServices.s3("DELETE", "/$bucket_name") sleep(2) end @@ -1020,7 +993,7 @@ end # PUT for vault in vault_names - AWSServices.glacier("PUT", "/-/vaults/$vault"; LOW_LVL_KWARGS...) + AWSServices.glacier("PUT", "/-/vaults/$vault") end try @@ -1028,15 +1001,11 @@ end tags = Dict("Tags" => LittleDict("Tag-01" => "Tag-01", "Tag-02" => "Tag-02")) for vault in vault_names - AWSServices.glacier( - "POST", "/-/vaults/$vault/tags?operation=add", tags; LOW_LVL_KWARGS... - ) + AWSServices.glacier("POST", "/-/vaults/$vault/tags?operation=add", tags) end for vault in vault_names - result_tags = Dict( - AWSServices.glacier("GET", "/-/vaults/$vault/tags"; LOW_LVL_KWARGS...) - ) + result_tags = Dict(AWSServices.glacier("GET", "/-/vaults/$vault/tags")) @test result_tags == tags end @@ -1045,17 +1014,17 @@ end # "class com.amazon.coral.value.json.numbers.TruncatingBigNumber can not be converted to an String" limit = "1" params = LittleDict("limit" => limit) - result = AWSServices.glacier("GET", "/-/vaults/", params; LOW_LVL_KWARGS...) + result = AWSServices.glacier("GET", "/-/vaults/", params) @test length(result["VaultList"]) == parse(Int, limit) finally # DELETE for vault in vault_names - AWSServices.glacier("DELETE", "/-/vaults/$vault"; LOW_LVL_KWARGS...) + AWSServices.glacier("DELETE", "/-/vaults/$vault") end end - result = AWSServices.glacier("GET", "/-/vaults"; LOW_LVL_KWARGS...) + result = AWSServices.glacier("GET", "/-/vaults") res_vault_names = [v["VaultName"] for v in result["VaultList"]] for vault in vault_names diff --git a/test/runtests.jl b/test/runtests.jl index f69adcf6d..b159e9dfa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -43,8 +43,6 @@ const TEST_MINIO = begin all(k -> haskey(ENV, k), ("MINIO_ACCESS_KEY", "MINIO_SECRET_KEY", "MINIO_REGION_NAME")) end -const LOW_LVL_KWARGS = (; features=(; use_response_type=true)) - aws = AWSConfig() function _now_formatted()