public void throw_error_if_no_connection_string_found() { var fake = new FakeConnectionStringProvider(); var cs = new ConnectionString(fake); Action action = () => cs.GetConnectionString(); action.ShouldThrow <Exception>(); }
public void get_decrypted_password_if_connection_string_salted() { var fake = new FakeConnectionStringProvider("data source=158.138.54.60;initial catalog=GestionFormation;user id=sa;password=\"secret:H8X8H7qBpO+L8gPmJmHTAQ==\""); var cs = new ConnectionString(fake); var result = cs.GetConnectionString(); result.ToLower().Should().Be("data source=158.138.54.60;initial catalog=gestionformation;user id=sa;password=123456"); fake.ConnectionString.Should().Contain("secret:"); }
public void write_encrypted_connection_in_file_if_no_salt_detected() { var fake = new FakeConnectionStringProvider("Data Source=158.138.54.60;Initial Catalog=GestionFormation;User ID=sa;Password=123456"); var cs = new ConnectionString(fake); var result = cs.GetConnectionString(); result.Should().Be("Data Source=158.138.54.60;Initial Catalog=GestionFormation;User ID=sa;Password=123456"); fake.ConnectionString.Should().Contain("secret:"); }
protected override void ExecuteBehavior() { // Provide external dependencies not needing specific behavior in this test var cacheProvider = new MemoryCacheProvider { MemoryCache = new MemoryCache("IsolatedForUnitTest") }; var configValueProvider = mocks.Stub <IConfigValueProvider>(); // Create Faked dependencies var connectionStringProvider = new FakeConnectionStringProvider(); var educationOrganizationCacheDataProvider = new FakeEducationOrganizationCacheDataProvider(connectionStringProvider); var suppliedIdentifierSet1 = new List <EducationOrganizationIdentifiers> { new EducationOrganizationIdentifiers( 9, "LocalEducationAgency", stateEducationAgencyId: 1, localEducationAgencyId: 9), new EducationOrganizationIdentifiers( 99, "School", stateEducationAgencyId: 1, localEducationAgencyId: 9, schoolId: 99), new EducationOrganizationIdentifiers( 999, "School", stateEducationAgencyId: 1, localEducationAgencyId: 9, schoolId: 999) }; var suppliedIdentifierSet2 = new List <EducationOrganizationIdentifiers> { new EducationOrganizationIdentifiers( 8, "LocalEducationAgency", stateEducationAgencyId: 1, localEducationAgencyId: 8), new EducationOrganizationIdentifiers( 88, "School", stateEducationAgencyId: 1, localEducationAgencyId: 8, schoolId: 88), new EducationOrganizationIdentifiers( 888, "School", stateEducationAgencyId: 1, localEducationAgencyId: 8, schoolId: 888) }; // Set up the cache data provider to return different data based on different connection strings educationOrganizationCacheDataProvider.AddResult("String1", suppliedIdentifierSet1); educationOrganizationCacheDataProvider.AddResult("String2", suppliedIdentifierSet2); // Create the cache var edOrgCache = new EducationOrganizationCache( cacheProvider, new EdFiOdsInstanceIdentificationProvider(connectionStringProvider), educationOrganizationCacheDataProvider, educationOrganizationCacheDataProvider, true); // First retrieve values for the first connection string connectionStringProvider.CurrentValue = "String1"; actual88ResultForString1 = edOrgCache.GetEducationOrganizationIdentifiers(88); actual99ResultForString1 = edOrgCache.GetEducationOrganizationIdentifiers(99); // Then retrieve values for the second connection string connectionStringProvider.CurrentValue = "String2"; actual88ResultForString2 = edOrgCache.GetEducationOrganizationIdentifiers(88); actual99ResultForString2 = edOrgCache.GetEducationOrganizationIdentifiers(99); }