Exemplo n.º 1
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            SqlServerConnectionString =
                Environment.GetEnvironmentVariable("SqlServerConnectionString", EnvironmentVariableTarget.Process);
            BlobStorageConnectionString =
                Environment.GetEnvironmentVariable("BlobStorageConnectionString", EnvironmentVariableTarget.Process);
            BlobStorageContainerNamePrefix =
                Environment.GetEnvironmentVariable("BlobStorageContainerNamePrefix", EnvironmentVariableTarget.Process) ?? string.Empty;
            DeleteKeysFromDbAfterBatching =
                (Environment.GetEnvironmentVariable("DeleteKeysFromDbAfterBatching", EnvironmentVariableTarget.Process) ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase);

            var regions =
                Environment.GetEnvironmentVariable("ExposureKeyRegions", EnvironmentVariableTarget.Process)
                ?? DbTemporaryExposureKey.DefaultRegion;

            ExposureKeyRegions = regions.Split(new[] { ';', ',', ':' });

            Database = new ExposureNotificationStorage(
                builder =>
            {
                if (string.IsNullOrEmpty(SqlServerConnectionString))
                {
                    builder.UseInMemoryDatabase("ChangeInProduction");
                }
                else
                {
                    builder.UseSqlServer(SqlServerConnectionString);
                }
            },
                initialize =>
            {
                //if (string.IsNullOrEmpty(SqlServerConnectionString))
                initialize.Database.EnsureCreated();
            });
        }
        public ExposureNotificationStorageTests()
        {
            var builder = new DbContextOptionsBuilder()
                          .UseInMemoryDatabase("ExposureNotificationStorageTests")
                          .ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning));
            var context = new ExposureNotificationContext(builder.Options);

            var settings = new Settings();
            var options  = Options.Create(settings);

            Storage = new ExposureNotificationStorage(context, options);
        }
Exemplo n.º 3
0
        static TemporaryExposureKeyExport GenerateRandomExport()
        {
            var date = DateTimeOffset.Now;
            var keys = new[]
            {
                Utils.GenerateRandomDbKey(date),
                Utils.GenerateRandomDbKey(date.AddMinutes(-1)),
                Utils.GenerateRandomDbKey(date.AddDays(-2)),
                Utils.GenerateRandomDbKey(date.AddHours(-6)),
                Utils.GenerateRandomDbKey(date.AddMilliseconds(-1)),
            };

            return(ExposureNotificationStorage.CreateUnsignedExport("ZA", 1, 1, keys));
        }
Exemplo n.º 4
0
        public void CreateExportSetsTimestampsCorrectly()
        {
            var date = DateTimeOffset.Now;
            var keys = new[]
            {
                Utils.GenerateRandomDbKey(date),
                Utils.GenerateRandomDbKey(date.AddMinutes(-1)),
                Utils.GenerateRandomDbKey(date.AddDays(-2)),
                Utils.GenerateRandomDbKey(date.AddHours(-6)),
                Utils.GenerateRandomDbKey(date.AddMilliseconds(-1)),
            };

            var export = ExposureNotificationStorage.CreateUnsignedExport("ZA", 1, 1, keys);

            Assert.NotNull(export);

            Assert.Equal((ulong)date.AddDays(-2).ToUnixTimeSeconds(), export.StartTimestamp);
            Assert.Equal((ulong)date.ToUnixTimeSeconds(), export.EndTimestamp);
        }
 public Tests()
 {
     Storage = new ExposureNotificationStorage(
         builder => builder.UseInMemoryDatabase("Tests"),
         initialize => initialize.Database.EnsureCreated());
 }
Exemplo n.º 6
0
 public override void Configure(IFunctionsHostBuilder builder)
 {
     Database = new ExposureNotificationStorage(
         builder => builder.UseInMemoryDatabase("ChangeInProduction"),
         initialize => initialize.Database.EnsureCreated());
 }
Exemplo n.º 7
0
 public DiagnosisUids(ExposureNotificationStorage storage)
 {
     this.storage = storage;
 }
Exemplo n.º 8
0
 public CreateBatchesFunction(ExposureNotificationStorage storage, IOptions <Settings> settings)
 {
     this.storage  = storage;
     this.settings = settings;
 }
        public CreateDummyKeys(ExposureNotificationStorage storage)
        {
            this.storage = storage;

            random = new Random();
        }
 public SelfDiagnosis(ExposureNotificationStorage storage, IOptions <Settings> settings)
 {
     this.storage  = storage;
     this.settings = settings;
 }