private TemporaryExposureKeyArgs[] GetRandomKeys(int WorkflowCount, int seed)
        {
            var random = new Random(seed);
            var WorkflowKeyValidatorConfig = new DefaultGaenTekValidatorConfig();
            var WorkflowValidatorConfig    = new DefaultGeanTekListValidationConfig();

            var result    = new List <TemporaryExposureKeyArgs>(WorkflowCount * WorkflowValidatorConfig.TemporaryExposureKeyCountMax);
            var keyBuffer = new byte[WorkflowKeyValidatorConfig.DailyKeyByteCount];

            for (var i = 0; i < WorkflowCount; i++)
            {
                var keyCount = 1 + random.Next(WorkflowValidatorConfig.TemporaryExposureKeyCountMax - 1);
                var keys     = new List <TemporaryExposureKeyArgs>(keyCount);
                for (var j = 0; j < keyCount; j++)
                {
                    random.NextBytes(keyBuffer);
                    keys.Add(new TemporaryExposureKeyArgs
                    {
                        KeyData               = keyBuffer,
                        RollingStartNumber    = WorkflowKeyValidatorConfig.RollingPeriodMin + j,
                        RollingPeriod         = 11,
                        TransmissionRiskLevel = 2
                    });
                }
                result.AddRange(keys);
            }
            return(result.ToArray());
        }
예제 #2
0
        public async Task Execute(int itemCount, Func <int, int> randomInt, Action <byte[]> randomBytes)
        {
            var luhnModNConfig           = new LuhnModNConfig();
            var tokenGenerator           = new GenerateKeysFirstAuthorisationToken(luhnModNConfig);
            var workflowValidationConfig = new DefaultGeanTekListValidationConfig();
            var tekValidatorConfig       = new DefaultGaenTekValidatorConfig();
            var writer = new KeysFirstEscrowInsertDbCommand(_DbContextProvider, new StandardUtcDateTimeProvider());
            var c      = new HttpPostKeysFirstEscrowCommand(
                writer,
                new KeysFirstEscrowValidator(
                    workflowValidationConfig,
                    new KeysFirstAuthorisationTokenLuhnModNValidator(luhnModNConfig),
                    new TemporaryExposureKeyValidator(tekValidatorConfig)),
                _DbContextProvider);

            var keyBuffer = new byte[tekValidatorConfig.DailyKeyByteCount];

            for (var i = 0; i < itemCount; i++)
            {
                var workflow = new KeysFirstEscrowArgs
                {
                    Token = tokenGenerator.Next(randomInt)
                };

                var keyCount = 1 + randomInt(workflowValidationConfig.TemporaryExposureKeyCountMax - 1);
                var keys     = new List <TemporaryExposureKeyArgs>(keyCount);
                for (var j = 0; j < keyCount; j++)
                {
                    randomBytes(keyBuffer);
                    keys.Add(new TemporaryExposureKeyArgs
                    {
                        KeyData            = Convert.ToBase64String(keyBuffer),
                        RollingStartNumber = tekValidatorConfig.RollingPeriodMin + j,
                        RollingPeriod      = 11,
                        RegionsOfInterest  = new [] { "NL" }
                    });
                }
                workflow.Items = keys.ToArray();

                await c.Execute(workflow);
            }
        }