public void GetCredentialFileAlibabaCloudCredentialWithAKType() { DefaultProfile profile = DefaultProfile.GetProfile(); profile.DefaultClientName = "default"; var defaultCredentialProvider = new DefaultCredentialProvider(profile, null); var homePath = defaultCredentialProvider.GetHomePath(); TestHelper.CreateIniFileWithAkType(homePath); var credential = (BasicCredentials)defaultCredentialProvider.GetAlibabaCloudClientCredential(); TestHelper.DeleteIniFile(homePath); Assert.NotNull(credential); Assert.NotNull(credential.GetAccessKeyId()); Assert.NotNull(credential.GetAccessKeySecret()); }
public void GetCredentialFileAlibabaCloudCredentialWithAKTypeButAKIsEmpty() { DefaultProfile profile = DefaultProfile.GetProfile(); profile.DefaultClientName = "default"; var defaultCredentialProvider = new DefaultCredentialProvider(profile, null); var homePath = defaultCredentialProvider.GetHomePath(); TestHelper.CreateIniFileWithAkTypeWithEmptyAK(homePath); var exception = Assert.Throws <ClientException>(() => { var credential = (BasicCredentials)defaultCredentialProvider.GetAlibabaCloudClientCredential(); }); TestHelper.DeleteIniFile(homePath); Assert.Equal("Missing required variable option for 'default Client'", exception.Message); }