public async Task CredentialsAreStored_StorageIsNotBeEmpty( [Frozen] ICredentialsStorageProvider storageProvider, Application.CredentialsNS.CredentialsRepository credentialsRepository) { // arrange var credentials = new Credentials("TestUsername", "TestPassword"); // act await credentialsRepository.StoreAsync(credentials); // assert storageProvider.GetStorage().Length.Should().BeGreaterThan(0, "credentials should have been stored"); }
public async Task StoringCredentialsTwice_ShouldLoadLatestCredentials( [Frozen] ICredentialsStorageProvider storageProvider, Application.CredentialsNS.CredentialsRepository credentialsRepository) { // arrange var firstCredentials = new Credentials("AAA", "BBB"); var secondCredentials = new Credentials("Z", "Y"); // act await credentialsRepository.StoreAsync(firstCredentials); await credentialsRepository.StoreAsync(secondCredentials); var loadedCredentials = await credentialsRepository.LoadAsync(); // assert loadedCredentials.Should().Be(secondCredentials); }
public async Task CredentialsAreStored_CredentialsAreEncrypted( [Frozen] ICredentialsStorageProvider storageProvider, Application.CredentialsNS.CredentialsRepository credentialsRepository) { // arrange var credentials = new Credentials("TestUsername", "TestPassword"); // act await credentialsRepository.StoreAsync(credentials); // assert string credentialStorageAsString; using (var streamReader = new StreamReader(storageProvider.GetStorage())) { credentialStorageAsString = await streamReader.ReadToEndAsync(); } credentialStorageAsString.Should() .NotContainAny(new[] { credentials.Username, credentials.Password }, "Storing unencrypted credentials is unsafe"); }
public CredentialsRepository(ICredentialsStorageProvider storageProvider) { m_storageProvider = storageProvider; }