public async Task TesetAccessKeyCredential() { AccessKeyCredential accessKeyCredential; try { Assert.Throws <ArgumentNullException>(() => new AccessKeyCredential(null, "test")); } catch (ArgumentNullException e) { Assert.Equal("Access key ID cannot be null.", e.Message); } try { Assert.Throws <ArgumentNullException>(() => new AccessKeyCredential("test", null)); } catch (ArgumentNullException e) { Assert.Equal("Access key secret cannot be null.", e.Message); } accessKeyCredential = new AccessKeyCredential("accessKeyId", "accessKeySecret"); Assert.NotNull(accessKeyCredential); Assert.Equal("accessKeyId", accessKeyCredential.GetAccessKeyId()); Assert.Equal("accessKeySecret", accessKeyCredential.GetAccessKeySecret()); Assert.Null(accessKeyCredential.GetSecurityToken()); Assert.Equal(AuthConstant.AccessKey, accessKeyCredential.GetCredentialType()); Assert.Equal("accessKeyId", await accessKeyCredential.GetAccessKeyIdAsync()); Assert.Equal("accessKeySecret", await accessKeyCredential.GetAccessKeySecretAsync()); Assert.Null(await accessKeyCredential.GetSecurityTokenAsync()); Assert.Equal(AuthConstant.AccessKey, await accessKeyCredential.GetCredentialTypeAsync()); }
public void TesetAccessKeyCredential() { AccessKeyCredential accessKeyCredential; try { Assert.Throws <ArgumentNullException>(() => new AccessKeyCredential(null, "test")); } catch (ArgumentNullException e) { Assert.Equal("Access key ID cannot be null.", e.Message); } try { Assert.Throws <ArgumentNullException>(() => new AccessKeyCredential("test", null)); } catch (ArgumentNullException e) { Assert.Equal("Access key secret cannot be null.", e.Message); } accessKeyCredential = new AccessKeyCredential("accessKeyId", "accessKeySecret"); Assert.NotNull(accessKeyCredential); Assert.Equal("accessKeyId", accessKeyCredential.AccessKeyId); Assert.Equal("accessKeySecret", accessKeyCredential.AccessKeySecret); Assert.Null(accessKeyCredential.SecurityToken); Assert.Equal(AuthConstant.AccessKey, accessKeyCredential.CredentialType); }
public void A() { var credential = new AccessKeyCredential("kid", "secret", 1, "read"); Assert.Equal("kid", credential.AccessKeyId); Assert.Equal("secret", credential.AccessKeySecret); Assert.Equal(1, credential.AccountId); Assert.Equal("read", credential.Scope); }
private AlibabaCloudCredentials GetAccessKeyCredential() { if (String.IsNullOrEmpty(this.accessKeyId) && String.IsNullOrEmpty(this.accessKeySecret) && String.IsNullOrEmpty(this.regionId)) { throw new ClientException("Missing required variable option for 'default Client'"); } AccessKeyCredential accessKeyCredential = new AccessKeyCredential(this.accessKeyId, this.accessKeySecret); return(accessKeyCredential); }