public ApplicationDatabaseTestFixture()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("testsettings.Development.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            _configuration = builder.Build();
            _configuration.Bind("OpcVault", _serviceConfig);
            _configuration.Bind("Auth", _clientConfig);
            _logger = SerilogTestLogger.Create <ApplicationDatabaseTestFixture>();
            if (!InvalidConfiguration())
            {
                RandomGenerator       = new ApplicationTestDataGenerator(_randomStart);
                _documentDBRepository = new OpcVaultDocumentDbRepository(_serviceConfig);
                ApplicationsDatabase  = CosmosDBApplicationsDatabaseFactory.Create(null, _serviceConfig, _documentDBRepository, _logger);
                // create test set
                ApplicationTestSet = new List <ApplicationTestData>();
                for (int i = 0; i < _testSetSize; i++)
                {
                    var randomApp = RandomGenerator.RandomApplicationTestData();
                    ApplicationTestSet.Add(randomApp);
                }
                // try initialize DB
                ApplicationsDatabase.Initialize().Wait();
            }
            RegistrationOk = false;
        }
Example #2
0
 public CertificateGroupTest(CertificateGroupTestFixture fixture, ITestOutputHelper log)
 {
     _logger   = SerilogTestLogger.Create <CertificateGroupTest>(log);
     _fixture  = fixture;
     _keyVault = _fixture.KeyVault;
     _fixture.SkipOnInvalidConfiguration();
 }
Example #3
0
        public CertificateGroupTestFixture()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("testsettings.Development.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();
            IConfigurationRoot configuration = builder.Build();

            configuration.Bind("OpcVault", _serviceConfig);
            configuration.Bind("Auth", _clientConfig);
            _logger = SerilogTestLogger.Create <CertificateGroupTestFixture>();
            if (!InvalidConfiguration())
            {
                RandomGenerator = new ApplicationTestDataGenerator();
                var timeid = (DateTime.UtcNow.ToFileTimeUtc() / 1000) % 10000;
                GroupId  = "GroupTestIssuerCA" + timeid.ToString();
                ConfigId = "GroupTestConfig" + timeid.ToString();
                var keyVaultServiceClient = KeyVaultServiceClient.Get(ConfigId, _serviceConfig, _clientConfig, _logger);
                KeyVault = new KeyVaultCertificateGroup(keyVaultServiceClient, _serviceConfig, _clientConfig, _logger);
                KeyVault.PurgeAsync(ConfigId, GroupId).Wait();
                KeyVault.CreateCertificateGroupConfiguration(GroupId, "CN=OPC Vault Cert Request Test CA, O=Microsoft, OU=Azure IoT", null).Wait();
            }
            KeyVaultInitOk = false;
        }
 public ApplicationDatabaseTest(ApplicationDatabaseTestFixture fixture, ITestOutputHelper log)
 {
     _fixture = fixture;
     // fixture
     _fixture.SkipOnInvalidConfiguration();
     _logger = SerilogTestLogger.Create <ApplicationDatabaseTest>(log);
     _applicationsDatabase = fixture.ApplicationsDatabase;
     _applicationTestSet   = fixture.ApplicationTestSet;
 }
 public CertificateRequestTest(CertificateRequestTestFixture fixture, ITestOutputHelper log)
 {
     _fixture = fixture;
     // fixture
     fixture.SkipOnInvalidConfiguration();
     _logger = SerilogTestLogger.Create <CertificateRequestTest>(log);
     _applicationsDatabase = fixture.ApplicationsDatabase;
     _certificateGroup     = fixture.CertificateGroup;
     _certificateRequest   = fixture.CertificateRequest;
     _applicationTestSet   = fixture.ApplicationTestSet;
     _randomSource         = new RandomSource(10815);
 }
        public CertificateRequestTestFixture()
        {
            RandomGenerator = new ApplicationTestDataGenerator(_randomStart);
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile("testsettings.Development.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();
            IConfigurationRoot configuration = builder.Build();

            configuration.Bind("OpcVault", _serviceConfig);
            configuration.Bind("Auth", _clientConfig);
            _logger = SerilogTestLogger.Create <CertificateRequestTestFixture>();
            if (!InvalidConfiguration())
            {
                _documentDBRepository = new OpcVaultDocumentDbRepository(_serviceConfig);
                ApplicationsDatabase  = CosmosDBApplicationsDatabaseFactory.Create(null, _serviceConfig, _documentDBRepository, _logger);

                var timeid = (DateTime.UtcNow.ToFileTimeUtc() / 1000) % 10000;
                _groupId  = "CertReqIssuerCA" + timeid.ToString();
                _configId = "CertReqConfig" + timeid.ToString();
                var keyVaultServiceClient = KeyVaultServiceClient.Get(_configId, _serviceConfig, _clientConfig, _logger);
                _keyVaultCertificateGroup = new KeyVaultCertificateGroup(keyVaultServiceClient, _serviceConfig, _clientConfig, _logger);
                _keyVaultCertificateGroup.PurgeAsync(_configId, _groupId).Wait();
                CertificateGroup = _keyVaultCertificateGroup;
                CertificateGroup = new KeyVaultCertificateGroup(keyVaultServiceClient, _serviceConfig, _clientConfig, _logger);
                CertificateGroup.CreateCertificateGroupConfiguration(_groupId, "CN=OPC Vault Cert Request Test CA, O=Microsoft, OU=Azure IoT", null).Wait();
                CertificateRequest = CosmosDBCertificateRequestFactory.Create(ApplicationsDatabase, CertificateGroup, _serviceConfig, _documentDBRepository, _logger);

                // create test set
                ApplicationTestSet = new List <ApplicationTestData>();
                for (int i = 0; i < _testSetSize; i++)
                {
                    var randomApp = RandomGenerator.RandomApplicationTestData();
                    ApplicationTestSet.Add(randomApp);
                }
                // try initialize DB
                ApplicationsDatabase.Initialize().Wait();
            }
            RegistrationOk = false;
        }