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> SendProofPresentationOfferAsync(OperationBody body) { var proofRecordId = body.Id; var proofPresentation = body.Data; throw new NotImplementedException(); }
public async Task <IActionResult> CreateSchemaAsync(OperationBody body) { var context = await _agentContextProvider.GetContextAsync(); var issuer = await _provisionService.GetProvisioningAsync(context.Wallet); var schema = body.Data; var schemaName = (string)schema["schema_name"]; var schemaVersion = (string)schema["schema_version"]; var schemaAttributes = schema["attributes"].ToObject <string[]>(); // The test client sends multiple create schema requests with // the same parameters. First check whether the schema already exists. var schemaId = $"{issuer.IssuerDid}:2:{schemaName}:{schemaVersion}"; var schemaString = await this.LookupSchemaByIdAsync(schemaId); // If the schema doesn't already exists, create it if (schemaString == null) { await _schemaService.CreateSchemaAsync( context : context, issuerDid : issuer.IssuerDid, name : schemaName, version : schemaVersion, attributeNames : schemaAttributes ); } return(Ok(new { schema_id = schemaId })); }
public async Task <IActionResult> AcceptRequestAsync(OperationBody body) { var connectionId = body.Id; var context = await _agentContextProvider.GetContextAsync(); // 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(5000); var THConnection = _connectionCache.Get <TestHarnessConnection>(connectionId); if (THConnection == null) { return(NotFound()); // Return early if not found } var(response, connection) = await _connectionService.CreateResponseAsync(context, connectionId); await _messageService.SendAsync(context, response, connection); THConnection.State = TestHarnessConnectionState.Responded; return(Ok(THConnection)); }
public async Task <IActionResult> SendPresentationProposalAsync(OperationBody body) { var connectionId = body.Id; var proposal = body.Data; throw new NotImplementedException(); }
public async Task <IActionResult> AcceptInvitationAsync(OperationBody body) { var connectionId = body.Id; var context = await _agentContextProvider.GetContextAsync(); var THConnection = _connectionCache.Get <TestHarnessConnection>(connectionId); if (THConnection == null) { return(NotFound()); // Return early if not found } ConnectionRecord connection; try { connection = await _connectionService.GetAsync(context, connectionId); } catch { return(NotFound()); } // Listen for connection response to update the state UpdateStateOnMessage(THConnection, TestHarnessConnectionState.Responded, _ => _.MessageType == MessageTypes.ConnectionResponse && _.RecordId == connection.Id); await _messageService.SendAsync(context.Wallet, THConnection.Request, connection); THConnection.State = TestHarnessConnectionState.Requested; return(Ok(THConnection)); }
public async Task <IActionResult> SendPingAsync(OperationBody body) { var connectionId = body.Id; var data = body.Data; var context = await _agentContextProvider.GetContextAsync(); var THConnection = _connectionCache.Get <TestHarnessConnection>(connectionId); if (THConnection == null) { return(NotFound()); // Return early if not found } ConnectionRecord connection; try { connection = await _connectionService.GetAsync(context, connectionId); } catch { return(NotFound()); } var message = new TrustPingMessage { Comment = (string)data["comment"] }; await _messageService.SendAsync(context.Wallet, message, connection); THConnection.State = TestHarnessConnectionState.Complete; return(Ok(THConnection)); }
public async Task <IActionResult> IssueCredentialAsync(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 threadId = body.Id; var context = await _agentContextProvider.GetContextAsync(); var THCredentialExchange = _credentialCache.Get <TestHarnessCredentialExchange>(threadId); // NOTE: We currently don't use the body from issue credential, but the data from the credential // I think this must be the same, otherwise a new offer must be sent before issuing other data var(credentialIssueMessage, credentialRecord) = await _credentialService.CreateCredentialAsync(context, THCredentialExchange.RecordId); var connection = await _connectionService.GetAsync(context, credentialRecord.ConnectionId); await _messageService.SendAsync(context, credentialIssueMessage, connection); THCredentialExchange.State = TestHarnessCredentialExchangeState.CredentialIssued; return(Ok(THCredentialExchange)); }
public static OperationBody Decode(XdrDataInputStream stream) { OperationBody decodedOperationBody = new OperationBody(); OperationType discriminant = OperationType.Decode(stream); decodedOperationBody.Discriminant = discriminant; switch (decodedOperationBody.Discriminant.InnerValue) { case OperationType.OperationTypeEnum.CREATE_ACCOUNT: decodedOperationBody.CreateAccountOp = CreateAccountOp.Decode(stream); break; case OperationType.OperationTypeEnum.PAYMENT: decodedOperationBody.PaymentOp = PaymentOp.Decode(stream); break; case OperationType.OperationTypeEnum.PATH_PAYMENT: decodedOperationBody.PathPaymentOp = PathPaymentOp.Decode(stream); break; case OperationType.OperationTypeEnum.MANAGE_OFFER: decodedOperationBody.ManageOfferOp = ManageOfferOp.Decode(stream); break; case OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER: decodedOperationBody.CreatePassiveOfferOp = CreatePassiveOfferOp.Decode(stream); break; case OperationType.OperationTypeEnum.SET_OPTIONS: decodedOperationBody.SetOptionsOp = SetOptionsOp.Decode(stream); break; case OperationType.OperationTypeEnum.CHANGE_TRUST: decodedOperationBody.ChangeTrustOp = ChangeTrustOp.Decode(stream); break; case OperationType.OperationTypeEnum.ALLOW_TRUST: decodedOperationBody.AllowTrustOp = AllowTrustOp.Decode(stream); break; case OperationType.OperationTypeEnum.ACCOUNT_MERGE: decodedOperationBody.Destination = AccountID.Decode(stream); break; case OperationType.OperationTypeEnum.INFLATION: break; case OperationType.OperationTypeEnum.MANAGE_DATA: decodedOperationBody.ManageDataOp = ManageDataOp.Decode(stream); break; case OperationType.OperationTypeEnum.BUMP_SEQUENCE: decodedOperationBody.BumpSequenceOp = BumpSequenceOp.Decode(stream); break; } return(decodedOperationBody); }
public async Task <IActionResult> SendCredentialProposalAsync(OperationBody body) { var context = await _agentContextProvider.GetContextAsync(); var proposal = body.Data; var connectionId = (string)proposal["connection_id"]; var credentialPreview = proposal["credential_proposal"].ToObject <CustomCredentialPreviewMessage>(); var credentialDefinitionId = (string)proposal["cred_def_id"]; var schemaId = (string)proposal["schema_id"]; var connection = await _connectionService.GetAsync(context, connectionId); // TODO: Handle AriesFrameworkException if connection not found var threadId = Guid.NewGuid().ToString(); credentialPreview.Attributes = CleanCredentialPreviewAttributes(credentialPreview.Attributes); // TODO: add support for v1.1 wich includes 'schema_issuer_did', 'schema_name', 'schema_version', 'issuer_did' // TODO: should we support in response to previous message? Not possible with AATH atm I think. var credentialProposeMessage = new CustomCredentialProposeMessage { Id = threadId, Comment = (string)proposal["comment"] ?? "hello", // ACA-Py requires comment CredentialProposal = credentialPreview, CredentialDefinitionId = credentialDefinitionId, SchemaId = schemaId }; var credentialRecord = new CredentialRecord { Id = Guid.NewGuid().ToString(), ConnectionId = connectionId, CredentialAttributesValues = credentialPreview.Attributes, CredentialDefinitionId = credentialDefinitionId, SchemaId = schemaId, // State should be proposal-received State = CredentialState.Offered }; credentialRecord.SetTag(TagConstants.Role, TagConstants.Holder); credentialRecord.SetTag(TagConstants.LastThreadId, threadId); await _recordService.AddAsync(context.Wallet, credentialRecord); var THCredentialExchange = new TestHarnessCredentialExchange { RecordId = credentialRecord.Id, ThreadId = threadId, State = TestHarnessCredentialExchangeState.ProposalSent, }; _credentialCache.Set(THCredentialExchange.ThreadId, THCredentialExchange); // Listen for credential offer to update the state UpdateStateOnMessage(THCredentialExchange, TestHarnessCredentialExchangeState.OfferReceived, _ => _.MessageType == MessageTypes.IssueCredentialNames.OfferCredential && _.ThreadId == THCredentialExchange.ThreadId); await _messageService.SendAsync(context.Wallet, credentialProposeMessage, connection); return(Ok(THCredentialExchange)); }
public static void Encode(XdrDataOutputStream stream, OperationBody encodedOperationBody) { stream.WriteInt((int)encodedOperationBody.Discriminant.InnerValue); switch (encodedOperationBody.Discriminant.InnerValue) { case OperationType.OperationTypeEnum.CREATE_ACCOUNT: CreateAccountOp.Encode(stream, encodedOperationBody.CreateAccountOp); break; case OperationType.OperationTypeEnum.PAYMENT: PaymentOp.Encode(stream, encodedOperationBody.PaymentOp); break; case OperationType.OperationTypeEnum.PATH_PAYMENT: PathPaymentOp.Encode(stream, encodedOperationBody.PathPaymentOp); break; case OperationType.OperationTypeEnum.MANAGE_SELL_OFFER: ManageSellOfferOp.Encode(stream, encodedOperationBody.ManageSellOfferOp); break; case OperationType.OperationTypeEnum.CREATE_PASSIVE_SELL_OFFER: CreatePassiveSellOfferOp.Encode(stream, encodedOperationBody.CreatePassiveSellOfferOp); break; case OperationType.OperationTypeEnum.SET_OPTIONS: SetOptionsOp.Encode(stream, encodedOperationBody.SetOptionsOp); break; case OperationType.OperationTypeEnum.CHANGE_TRUST: ChangeTrustOp.Encode(stream, encodedOperationBody.ChangeTrustOp); break; case OperationType.OperationTypeEnum.ALLOW_TRUST: AllowTrustOp.Encode(stream, encodedOperationBody.AllowTrustOp); break; case OperationType.OperationTypeEnum.ACCOUNT_MERGE: AccountID.Encode(stream, encodedOperationBody.Destination); break; case OperationType.OperationTypeEnum.INFLATION: break; case OperationType.OperationTypeEnum.MANAGE_DATA: ManageDataOp.Encode(stream, encodedOperationBody.ManageDataOp); break; case OperationType.OperationTypeEnum.BUMP_SEQUENCE: BumpSequenceOp.Encode(stream, encodedOperationBody.BumpSequenceOp); break; case OperationType.OperationTypeEnum.MANAGE_BUY_OFFER: ManageBuyOfferOp.Encode(stream, encodedOperationBody.ManageBuyOfferOp); break; } }
public async Task <IActionResult> SendPresentationRequestAsync(OperationBody body) { // TODO: ID can be both pres_exchange_id OR connection_id // Find out how this works exactly. Probably as different key var proofRecordId = body.Id; var proofRequest = body.Data; throw new NotImplementedException(); }
/// <summary> /// Sets all values back to their defaults, so this object can be reused. /// </summary> public void Reset() { if (Data != null) { Data.Dispose(); } Buffer = new byte[512]; Data = new MemoryStream(); BytesReceived = 0; Header = new OperationHeader(); Body = new OperationBody(); }
public static Operation Decode(IByteReader stream) { Operation decodedOperation = new Operation(); int sourceAccountPresent = XdrEncoding.DecodeInt32(stream); if (sourceAccountPresent != 0) { decodedOperation.SourceAccount = AccountID.Decode(stream); } decodedOperation.Body = OperationBody.Decode(stream); return(decodedOperation); }
public static Operation Decode(XdrDataInputStream stream) { Operation decodedOperation = new Operation(); int SourceAccountPresent = stream.ReadInt(); if (SourceAccountPresent != 0) { decodedOperation.SourceAccount = MuxedAccount.Decode(stream); } decodedOperation.Body = OperationBody.Decode(stream); return(decodedOperation); }
public async Task <IActionResult> StoreCredentialAsync(OperationBody body) { var threadId = body.Id; var context = await _agentContextProvider.GetContextAsync(); var THCredentialExchange = _credentialCache.Get <TestHarnessCredentialExchange>(threadId); var credentialRecord = await _credentialService.GetAsync(context, THCredentialExchange.RecordId); THCredentialExchange.CredentialId = credentialRecord.CredentialId; THCredentialExchange.State = TestHarnessCredentialExchangeState.Done; return(Ok(THCredentialExchange)); }
public static void Encode(IByteWriter stream, Operation encodedOperation) { if (encodedOperation.SourceAccount != null) { XdrEncoding.EncodeInt32(1, stream); AccountID.Encode(stream, encodedOperation.SourceAccount); } else { XdrEncoding.EncodeInt32(0, stream); } OperationBody.Encode(stream, encodedOperation.Body); }
public static void Encode(XdrDataOutputStream stream, Operation encodedOperation) { if (encodedOperation.SourceAccount != null) { stream.WriteInt(1); MuxedAccount.Encode(stream, encodedOperation.SourceAccount); } else { stream.WriteInt(0); } OperationBody.Encode(stream, encodedOperation.Body); }
public static void Encode(IByteWriter stream, OperationBody encodedOperationBody) { XdrEncoding.EncodeInt32((int)encodedOperationBody.Discriminant.InnerValue, stream); switch (encodedOperationBody.Discriminant.InnerValue) { case OperationType.OperationTypeEnum.CREATE_ACCOUNT: CreateAccountOp.Encode(stream, encodedOperationBody.CreateAccountOp); break; case OperationType.OperationTypeEnum.PAYMENT: PaymentOp.Encode(stream, encodedOperationBody.PaymentOp); break; case OperationType.OperationTypeEnum.PATH_PAYMENT: PathPaymentOp.Encode(stream, encodedOperationBody.PathPaymentOp); break; case OperationType.OperationTypeEnum.MANAGE_OFFER: ManageOfferOp.Encode(stream, encodedOperationBody.ManageOfferOp); break; case OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER: CreatePassiveOfferOp.Encode(stream, encodedOperationBody.CreatePassiveOfferOp); break; case OperationType.OperationTypeEnum.SET_OPTIONS: SetOptionsOp.Encode(stream, encodedOperationBody.SetOptionsOp); break; case OperationType.OperationTypeEnum.CHANGE_TRUST: ChangeTrustOp.Encode(stream, encodedOperationBody.ChangeTrustOp); break; case OperationType.OperationTypeEnum.ALLOW_TRUST: AllowTrustOp.Encode(stream, encodedOperationBody.AllowTrustOp); break; case OperationType.OperationTypeEnum.ACCOUNT_MERGE: AccountID.Encode(stream, encodedOperationBody.Destination); break; case OperationType.OperationTypeEnum.INFLATION: break; case OperationType.OperationTypeEnum.MANAGE_DATA: ManageDataOp.Encode(stream, encodedOperationBody.ManageDataOp); break; } }
public async Task <IActionResult> SendPresentationRequestAsync(OperationBody body) { // NOTE: AATH can only start from presentation request, not respond to previous message var context = await _agentContextProvider.GetContextAsync(); var presentationRequest = body.Data; var connectionId = (string)presentationRequest["connection_id"]; var presentationRequestMessage = presentationRequest["presentation_proposal"]["request_presentations~attach"]["data"]; var proofRequest = new ProofRequest { Name = (string)presentationRequestMessage["name"] ?? "test proof", Version = (string)presentationRequestMessage["version"] ?? "1.0", Nonce = await AnonCreds.GenerateNonceAsync(), RequestedAttributes = presentationRequestMessage["requested_attributes"]?.ToObject <Dictionary <string, ProofAttributeInfo> >() ?? new Dictionary <string, ProofAttributeInfo> { }, RequestedPredicates = presentationRequestMessage["requested_predicates"]?.ToObject <Dictionary <string, ProofPredicateInfo> >() ?? new Dictionary <string, ProofPredicateInfo> { } }; _logger.LogInformation("SendPresentationRequest {proofRequest}", proofRequest.ToJson()); var(requestPresentationMessage, proofRecord) = await _proofService.CreateRequestAsync(context, proofRequest, connectionId); var connection = await _connectionService.GetAsync(context, connectionId); var THPresentationExchange = new TestHarnessPresentationExchange { RecordId = proofRecord.Id, ThreadId = proofRecord.GetTag(TagConstants.LastThreadId), State = TestHarnessPresentationExchangeState.RequestSent }; _proofCache.Set(THPresentationExchange.ThreadId, THPresentationExchange); UpdateStateOnMessage(THPresentationExchange, TestHarnessPresentationExchangeState.PresentationReceived, _ => _.MessageType == MessageTypes.PresentProofNames.Presentation && _.ThreadId == THPresentationExchange.ThreadId); _logger.LogDebug("Send Presentation Request {requestPresentationMessage}", requestPresentationMessage.ToJson()); await _messageService.SendAsync(context, requestPresentationMessage, connection); return(Ok(THPresentationExchange)); }
public async Task <IActionResult> ReceiveInvitationAsync(OperationBody body) { var invitation = body.Data.ToObject <ConnectionInvitationMessage>(); var context = await _agentContextProvider.GetContextAsync(); var(request, record) = await _connectionService.CreateRequestAsync(context, invitation); var THConnection = new TestHarnessConnection { ConnectionId = record.Id, State = TestHarnessConnectionState.Invited, Request = request }; _connectionCache.Set(record.Id, THConnection); return(Ok(THConnection)); }
public async Task <IActionResult> AcceptRequestAsync(OperationBody body) { var connectionId = body.Id; var context = await _agentContextProvider.GetContextAsync(); var THConnection = _connectionCache.Get <TestHarnessConnection>(connectionId); if (THConnection == null) { return(NotFound()); // Return early if not found } var(response, connection) = await _connectionService.CreateResponseAsync(context, connectionId); await _messageService.SendAsync(context.Wallet, response, connection); THConnection.State = TestHarnessConnectionState.Responded; return(Ok(THConnection)); }
public async Task <IActionResult> IssueCredentialAsync(OperationBody body) { var threadId = body.Id; var context = await _agentContextProvider.GetContextAsync(); var THCredentialExchange = _credentialCache.Get <TestHarnessCredentialExchange>(threadId); // NOTE: We currently don't use the body from issue credential, but the data from the credential // I think this must be the same, otherwise a new offer must be sent before issuing other data var(credentialIssueMessage, credentialRecord) = await _credentialService.CreateCredentialAsync(context, THCredentialExchange.RecordId); var connection = await _connectionService.GetAsync(context, credentialRecord.ConnectionId); await _messageService.SendAsync(context, credentialIssueMessage, connection); THCredentialExchange.State = TestHarnessCredentialExchangeState.CredentialIssued; return(Ok(THCredentialExchange)); }
public override OperationBody ToOperationBody() { var op = new BumpSequenceOp(); var bumpTo = new xdr.Int64 { InnerValue = BumpTo }; var sequenceNumber = new SequenceNumber { InnerValue = bumpTo }; op.BumpTo = sequenceNumber; var body = new OperationBody { Discriminant = OperationType.Create(OperationType.OperationTypeEnum.BUMP_SEQUENCE), BumpSequenceOp = op }; return(body); }
public async Task <IActionResult> IssueCredentialAsync(OperationBody body) { await Task.Delay(5000); var threadId = body.Id; var context = await _agentContextProvider.GetContextAsync(); var THCredentialExchange = _credentialCache.Get <TestHarnessCredentialExchange>(threadId); // TODO: should we use body.Data? This can contain an optional comment. var(credentialIssueMessage, credentialRecord) = await _credentialService.CreateCredentialAsync(context, THCredentialExchange.RecordId); var connection = await _connectionService.GetAsync(context, credentialRecord.ConnectionId); await _messageService.SendAsync(context.Wallet, credentialIssueMessage, connection); THCredentialExchange.State = TestHarnessCredentialExchangeState.CredentialIssued; return(Ok(THCredentialExchange)); }
public async Task <IActionResult> SendCredentialRequestAsync(OperationBody body) { // Indy does not support startign from a credential-request. So the id is always the thread id var threadId = body.Id; var THCredentialExchange = _credentialCache.Get <TestHarnessCredentialExchange>(threadId); var context = await _agentContextProvider.GetContextAsync(); var(credentialRequest, credentialRecord) = await _credentialService.CreateRequestAsync(context, THCredentialExchange.RecordId); THCredentialExchange.State = TestHarnessCredentialExchangeState.RequestSent; // Listen for issue credential to update the state UpdateStateOnMessage(THCredentialExchange, TestHarnessCredentialExchangeState.CredentialReceived, _ => new[] { MessageTypes.IssueCredentialNames.IssueCredential, MessageTypesHttps.IssueCredentialNames.IssueCredential }.Contains(_.MessageType) && _.ThreadId == THCredentialExchange.ThreadId); var connection = await _connectionService.GetAsync(context, credentialRecord.ConnectionId); await _messageService.SendAsync(context, credentialRequest, connection); return(Ok(THCredentialExchange)); }
public async Task <IActionResult> SendCredentialRequestAsync(OperationBody body) { // Indy does not support startign from a credential-request. So the id is always the thread id var threadId = body.Id; var THCredentialExchange = _credentialCache.Get <TestHarnessCredentialExchange>(threadId); var context = await _agentContextProvider.GetContextAsync(); var(credentialRequest, credentialRecord) = await _credentialService.CreateRequestAsync(context, THCredentialExchange.RecordId); THCredentialExchange.State = TestHarnessCredentialExchangeState.RequestSent; // TODO: find better way to listen for changes. As the state can move to other statest than just CredentialReceived // Listen for issue credential to update the state UpdateStateOnMessage(THCredentialExchange, TestHarnessCredentialExchangeState.CredentialReceived, _ => _.MessageType == MessageTypes.IssueCredentialNames.IssueCredential && _.ThreadId == THCredentialExchange.ThreadId); var connection = await _connectionService.GetAsync(context, credentialRecord.ConnectionId); // TODO: Handle AriesFrameworkException if connection not found await _messageService.SendAsync(context.Wallet, credentialRequest, connection); return(Ok(THCredentialExchange)); }
public async Task <IActionResult> CreateCredentialDefinitionAsync(OperationBody body) { var context = await _agentContextProvider.GetContextAsync(); var issuer = await _provisionService.GetProvisioningAsync(context.Wallet); var credentialDefinition = body.Data; var schemaId = (string)credentialDefinition["schema_id"]; var tag = (string)credentialDefinition["tag"]; var supportRevocation = (bool)credentialDefinition["support_revocation"]; // Needed to construct credential definition id var schema = JObject.Parse(await _schemaService.LookupSchemaAsync(context, schemaId)); var schemaSeqNo = (string)schema["seqNo"]; var signatureType = "CL"; // TODO: can we make this variable? // The test client sends multiple create credential definition requests with // the same parameters. First check whether the credential definition already exists. var credentialDefinitionId = $"{issuer.IssuerDid}:3:{signatureType}:{schemaSeqNo}:{tag}"; var credentialDefinitionString = await this.LookupCredentialDefinitionByIdAsync(credentialDefinitionId); // If the credential defintion doesn't already exists, create it if (credentialDefinitionString == null) { await _schemaService.CreateCredentialDefinitionAsync(context, new CredentialDefinitionConfiguration { SchemaId = schemaId, Tag = tag, EnableRevocation = supportRevocation, IssuerDid = issuer.IssuerDid }); } return(Ok(new { credential_definition_id = credentialDefinitionId })); }
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)); }
public async Task <IActionResult> SendProofPresentationAsync(OperationBody body) { var context = await _agentContextProvider.GetContextAsync(); var threadId = body.Id; var THPresentationExchange = _proofCache.Get <TestHarnessPresentationExchange>(threadId); var requestedCredentialsJson = body.Data; var requestedCredentials = requestedCredentialsJson.ToObject <RequestedCredentials>(); _logger.LogInformation("SendProofPresentation {requestedCredentials}", requestedCredentials.ToJson()); var(presentationMessage, proofRecord) = await _proofService.CreatePresentationAsync(context, THPresentationExchange.RecordId, requestedCredentials); var connection = await _connectionService.GetAsync(context, proofRecord.ConnectionId); THPresentationExchange.State = TestHarnessPresentationExchangeState.PresentationSent; _logger.LogDebug("Send Presentation {presentationMessage}", presentationMessage.ToJson()); await _messageService.SendAsync(context, presentationMessage, connection); return(Ok(THPresentationExchange)); }
public static OperationBody Decode(IByteReader stream) { OperationBody decodedOperationBody = new OperationBody(); decodedOperationBody.Discriminant = OperationType.Decode(stream); switch (decodedOperationBody.Discriminant.InnerValue) { case OperationType.OperationTypeEnum.CREATE_ACCOUNT: decodedOperationBody.CreateAccountOp = CreateAccountOp.Decode(stream); break; case OperationType.OperationTypeEnum.PAYMENT: decodedOperationBody.PaymentOp = PaymentOp.Decode(stream); break; case OperationType.OperationTypeEnum.PATH_PAYMENT: decodedOperationBody.PathPaymentOp = PathPaymentOp.Decode(stream); break; case OperationType.OperationTypeEnum.MANAGE_OFFER: decodedOperationBody.ManageOfferOp = ManageOfferOp.Decode(stream); break; case OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER: decodedOperationBody.CreatePassiveOfferOp = CreatePassiveOfferOp.Decode(stream); break; case OperationType.OperationTypeEnum.SET_OPTIONS: decodedOperationBody.SetOptionsOp = SetOptionsOp.Decode(stream); break; case OperationType.OperationTypeEnum.CHANGE_TRUST: decodedOperationBody.ChangeTrustOp = ChangeTrustOp.Decode(stream); break; case OperationType.OperationTypeEnum.ALLOW_TRUST: decodedOperationBody.AllowTrustOp = AllowTrustOp.Decode(stream); break; case OperationType.OperationTypeEnum.ACCOUNT_MERGE: decodedOperationBody.Destination = AccountID.Decode(stream); break; case OperationType.OperationTypeEnum.INFLATION: break; case OperationType.OperationTypeEnum.MANAGE_DATA: decodedOperationBody.ManageDataOp = ManageDataOp.Decode(stream); break; } return decodedOperationBody; }