Ejemplo n.º 1
0
        public async Task <IActionResult> VerifyPresentation(OperationBody body)
        {
            var context = await _agentContextProvider.GetContextAsync();

            var threadId = body.Id;
            var THPresentationExchange = _proofCache.Get <TestHarnessPresentationExchange>(threadId);
            var proofRecord            = await _proofService.GetByThreadIdAsync(context, THPresentationExchange.ThreadId);

            var connectionRecord = await _connectionService.GetAsync(context, proofRecord.ConnectionId);

            _logger.LogInformation("VerifyPresentation {proofRecord}", proofRecord.ToJson());

            var isValid = await _proofService.VerifyProofAsync(context, THPresentationExchange.RecordId);

            if (!isValid)
            {
                return(Problem("Proof is not valid"));
            }

            THPresentationExchange.State = TestHarnessPresentationExchangeState.Done;
            var ackPresentationMessage = new AckPresentationMessage()
            {
                Status = "OK"
            };

            ackPresentationMessage.ThreadFrom(threadId);

            await _messageService.SendAsync(context, ackPresentationMessage, connectionRecord);

            return(Ok(THPresentationExchange));
        }
        public async Task <IActionResult> VerifyPresentation(OperationBody body)
        {
            // Adding a delay here. It seems that with the removal of the state checks in the tests,
            // Some agents are not yet in the appropriate state for this call.
            // TODO There may be a better way to do this but adding the wait is a quick fix to get the tests
            // running again.
            await Task.Delay(10000);

            var context = await _agentContextProvider.GetContextAsync();

            var threadId = body.Id;
            var THPresentationExchange = _proofCache.Get <TestHarnessPresentationExchange>(threadId);
            var proofRecord            = await _proofService.GetByThreadIdAsync(context, THPresentationExchange.ThreadId);

            var connectionRecord = await _connectionService.GetAsync(context, proofRecord.ConnectionId);

            _logger.LogInformation("VerifyPresentation {proofRecord}", proofRecord.ToJson());

            var isValid = await _proofService.VerifyProofAsync(context, THPresentationExchange.RecordId);

            if (!isValid)
            {
                return(Problem("Proof is not valid"));
            }

            THPresentationExchange.State = TestHarnessPresentationExchangeState.Done;
            var ackPresentationMessage = new AckPresentationMessage()
            {
                Status = "OK"
            };

            ackPresentationMessage.ThreadFrom(threadId);

            await _messageService.SendAsync(context, ackPresentationMessage, connectionRecord);

            return(Ok(THPresentationExchange));
        }