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 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 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);
        }