Beispiel #1
0
        public async Task DoActionAsyncTest()
        {
            HttpRequest httpRequest = new HttpRequest("https://www.aliyun.com", new Dictionary <string, string>());

            httpRequest.Method         = MethodType.Get;
            httpRequest.ConnectTimeout = 10000;
            httpRequest.ReadTimeout    = 10000;
            CompatibleUrlConnClient client       = new CompatibleUrlConnClient();
            HttpResponse            httpResponse = await client.DoActionAsync(httpRequest);

            Assert.NotNull(httpResponse);

            httpRequest                = new HttpRequest("http://www.aliyun.com");
            httpRequest.Method         = MethodType.Get;
            httpRequest.ConnectTimeout = 1;
            httpRequest.ReadTimeout    = 1;
            await Assert.ThrowsAsync <CredentialException>(async() => await client.DoActionAsync(httpRequest));

            httpRequest = new HttpRequest();
            httpRequest.ConnectTimeout = 10000;
            httpRequest.ReadTimeout    = 10000;
            Assert.Equal("URL is null for HttpRequest.",
                         (await Assert.ThrowsAsync <InvalidDataException>(async() => await client.DoActionAsync(httpRequest))).Message
                         );

            httpRequest = new HttpRequest("http://www.aliyun.com");
            httpRequest.ConnectTimeout = 10000;
            httpRequest.ReadTimeout    = 10000;
            Assert.Equal("Method is null for HttpRequest.",
                         (await Assert.ThrowsAsync <InvalidDataException>(async() => await client.DoActionAsync(httpRequest))).Message
                         );
        }
        public IAlibabaCloudCredentials GetCredentials()
        {
            CompatibleUrlConnClient client = new CompatibleUrlConnClient();

            if (string.IsNullOrWhiteSpace(roleName))
            {
                GetRoleName(client);
                SetCredentialUrl();
            }
            return(CreateCredential(client));
        }
        public async Task <IAlibabaCloudCredentials> GetCredentialsAsync()
        {
            CompatibleUrlConnClient client = new CompatibleUrlConnClient();

            if (string.IsNullOrWhiteSpace(roleName))
            {
                await GetRoleNameAsync(client);

                SetCredentialUrl();
            }
            return(await CreateCredentialAsync(client));
        }
Beispiel #4
0
        public IAlibabaCloudCredentials GetCredentials()
        {
            CompatibleUrlConnClient client = new CompatibleUrlConnClient();

            return(CreateCredential(client));
        }
        public async Task <IAlibabaCloudCredentials> GetCredentialsAsync()
        {
            CompatibleUrlConnClient client = new CompatibleUrlConnClient();

            return(await CreateCredentialAsync(client));
        }