public void BasicRoaTokenConnection() { if (FeatureCommon.GetRoleArn().Equals("FakeRoleArn")) { return; } DefaultProfile.ClearProfile(); var basciCredential = new BasicSessionCredentials(FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret(), FeatureCommon.GetToken()); var profile = DefaultProfile.GetProfile(FeatureCommon.GetRegionId(), FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var client = new DefaultAcsClient(profile, basciCredential); var request = new CommonRequest(); request.Domain = "ros.aliyuncs.com"; request.Version = "2015-09-01"; request.Action = "DescribeResourceTypes"; request.UriPattern = "/resource_types"; request.Method = MethodType.GET; var response = client.GetCommonResponse(request); Assert.Equal(200, response.HttpStatus); Assert.NotNull(response.Data); }
public void UnicodeAndQueryTest() { if (FeatureCommon.GetRoleArn().Equals("FakeRoleArn")) { return; } DefaultProfile.ClearProfile(); var basciCredential = new BasicSessionCredentials(FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret(), FeatureCommon.GetToken()); var profile = DefaultProfile.GetProfile(FeatureCommon.GetRegionId(), FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var client = new DefaultAcsClient(profile, basciCredential); var request = new CommonRequest(); request.TimeoutInMilliSeconds = 30000; request.Domain = "ros.aliyuncs.com"; request.Version = "2015-09-01"; request.Action = "DescribeResourceTypes"; request.UriPattern = "/resource_types"; request.Method = MethodType.GET; request.QueryParameters.Add("testParams", "SDFSDFSAetTEWTEWQO(∩_∩)O哈哈~"); var response = client.GetCommonResponse(request); Assert.Equal(200, response.HttpStatus); Assert.NotNull(response.Data); }
public void BasicRpcStsTokenConnectionsTest() { if (FeatureCommon.GetRoleArn().Equals("FakeRoleArn")) { return; } DefaultProfile.ClearProfile(); var basciCredential = new BasicSessionCredentials(FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret(), FeatureCommon.GetToken()); var profile = DefaultProfile.GetProfile(FeatureCommon.GetRegionId(), FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var client = new DefaultAcsClient(profile, basciCredential); var request = new DescribeAccessControlListsRequest(); var response = client.GetAcsResponse(request); Assert.NotNull(response); }
public void TestAddExistingEndpointManually() { var request = new DescribeRegionsRequest(); DefaultProfile.ClearProfile(); var profile = DefaultProfile.GetProfile("cn-wenzhou", FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var testClient = new DefaultAcsClient(profile); profile.AddEndpoint("cn-hangzhou", "cn-hangzhou", "Ecs", "abc.cn-hangzhou.endpoint-test.exception.com"); var response = testClient.GetAcsResponse(request); Assert.NotNull(response); }
public void STSAssumeRoleCredentialWithPolicyTest() { if (FeatureCommon.GetRoleArn().Equals("FakeRoleArn")) { return; } var profile = DefaultProfile.GetProfile("cn-shanghai", FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var basicCredential = new BasicCredentials(FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var policy = "{ \"Version\": \"1\",\"Statement\": [{\"Effect\": \"Deny\",\"Action\": \"vpc:Create*\",\"Resource\": \"acs:vpc:cn-hangzhou:*:*\"}]}"; var provider = new STSAssumeRoleSessionCredentialsProvider(basicCredential, FeatureCommon.GetRoleArn(), policy, profile); var client = new DefaultAcsClient(profile, provider); var request = new CreateVpcRequest(); var exception = Assert.Throws <ClientException>(() => { var response = client.GetAcsResponse(request); }); Assert.Contains( "Forbidden.RAM : User not authorized to operate on the specified resource, or this API doesn't support RAM.", exception.Message); }
public void SdkManageTokenTest() { if (FeatureCommon.GetRoleArn().Equals("FakeRoleArn")) { return; } DefaultProfile.ClearProfile(); var profile = DefaultProfile.GetProfile("cn-hangzhou", FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var basicCredential = new BasicCredentials(FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var provider = new STSAssumeRoleSessionCredentialsProvider(basicCredential, FeatureCommon.GetRoleArn(), profile); var client = new DefaultAcsClient(profile, provider); var request = new DescribeAccessPointsRequest(); var response = client.GetAcsResponse(request); Assert.NotNull(response); Assert.True(0 <= response.TotalCount); }
public void BadFormatTypeTest() { var request = new ActiveFlowLogRequest(); request.FlowLogId = "testFlow"; DefaultProfile.ClearProfile(); var profile = DefaultProfile.GetProfile("cn-hangzhou", FeatureCommon.GetBasicAccessKeyId(), FeatureCommon.GetBasicAccessKeySecret()); var client = new DefaultAcsClient(profile); var exceptionMsg = Assert.Throws <ClientException>(() => { var response = client.GetAcsResponse(request); }); Assert.Equal("The specfied instance is not existed.", exceptionMsg.ErrorMessage); Assert.Equal("InvalidInstanceId.NotFound", exceptionMsg.ErrorCode); }