Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> PostWorkflow([FromBody] KeysFirstEscrowArgs args, [FromServices] HttpPostKeysFirstEscrowCommand command)
 {
     return(await command.Execute(args));
 }