public static async Task <(ProofRecord holderProofRecord, ProofRecord requestorProofRecord)> ProposerInitiatedProofProtocolAsync( IProofService proofService, IProducerConsumerCollection <AgentMessage> messages, ConnectionRecord holderConnection, ConnectionRecord requestorConnection, IAgentContext holderContext, IAgentContext requestorContext, ProofProposal proofProposalObject) { // Holder sends a proof proposal var(holderProposalMessage, holderProofProposalRecord) = await proofService.CreateProposalAsync(holderContext, proofProposalObject, holderConnection.Id); messages.TryAdd(holderProposalMessage); Assert.True(holderProofProposalRecord.State == ProofState.Proposed); // Requestor accepts the proposal and builds a proofRequest var requestorProposalMessage = FindContentMessage <ProposePresentationMessage>(messages); Assert.NotNull(requestorProposalMessage); //Requestor stores the proof proposal var requestorProofProposalRecord = await proofService.ProcessProposalAsync(requestorContext, requestorProposalMessage, requestorConnection); Assert.Equal(ProofState.Proposed, requestorProofProposalRecord.State); var proposal = requestorProofProposalRecord.ProposalJson.ToObject <ProofProposal>(); Assert.Equal("Hello, World", proposal.Comment); Assert.NotNull(proposal.ProposedAttributes); Console.WriteLine(requestorProofProposalRecord.ProposalJson); // Requestor sends a proof request var(requestorRequestMessage, requestorProofRequestRecord) = await proofService.CreateRequestFromProposalAsync( requestorContext, new ProofRequestParameters { Name = "Test", Version = "1.0" }, requestorProofProposalRecord.Id, requestorConnection.Id); messages.TryAdd(requestorRequestMessage); Assert.Equal(ProofState.Requested, requestorProofRequestRecord.State); return(await ProofProtocolAsync(proofService, messages, holderConnection, requestorConnection, holderContext, requestorContext, requestorProofRequestRecord)); }
public async Task CreateProofProposalThrowsInvalidParameterFormat() { // Setup secure connection between issuer and holder var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync( _connectionService, _messages, _issuerWallet, _holderWallet); var proofProposal = new ProofProposal { Comment = "Hello, World", ProposedAttributes = new List <ProposedAttribute> { new ProposedAttribute { Name = "first_name", CredentialDefinitionId = "1", SchemaId = "1", IssuerDid = "1", Referent = "Proof of First Name", Value = "Joe" }, new ProposedAttribute { Name = "second_name", CredentialDefinitionId = "2", SchemaId = "2", IssuerDid = "2", Referent = "Proof of First Name", Value = "Joe" } }, ProposedPredicates = new List <ProposedPredicate> { new ProposedPredicate { Name = "salary", CredentialDefinitionId = "1", Predicate = ">", Threshold = 99999, Referent = "Proof of Salary > $99,999" } } }; var ex = await Assert.ThrowsAsync <AriesFrameworkException>(async() => await _proofService.CreateProposalAsync(_holderWallet, proofProposal, holderConnection.Id)); Assert.True(ex.ErrorCode == ErrorCode.InvalidParameterFormat); var len = proofProposal.ProposedAttributes.Count - 1; proofProposal.ProposedAttributes.Remove(proofProposal.ProposedAttributes[len]); proofProposal.ProposedPredicates.Add(new ProposedPredicate { Name = "name", CredentialDefinitionId = "2", Predicate = ">", Threshold = 99999, Referent = "Proof of Salary > $99,999" }); ex = await Assert.ThrowsAsync <AriesFrameworkException>(async() => await _proofService.CreateProposalAsync(_holderWallet, proofProposal, holderConnection.Id)); Assert.True(ex.ErrorCode == ErrorCode.InvalidParameterFormat); }
public async Task CreateProofProposalSuccesfully() { var proposedAttributes = new List <ProposedAttribute> { new ProposedAttribute { Name = "first_name", CredentialDefinitionId = "1", SchemaId = "1", IssuerDid = "1", Referent = "Proof of Name", Value = "Joe" }, new ProposedAttribute { Name = "second_name", CredentialDefinitionId = "1", SchemaId = "1", IssuerDid = "1", Referent = "Proof of Name", Value = "Joe" }, new ProposedAttribute { Name = "age", CredentialDefinitionId = "1", SchemaId = "1", IssuerDid = "1", Referent = "Proof of Age", Value = "Joe" } }; var proposedPredicates = new List <ProposedPredicate> { new ProposedPredicate { Name = "salary", CredentialDefinitionId = "1", Predicate = ">", Threshold = 99999, Referent = "Proof of Salary > $99,999" }, new ProposedPredicate { Name = "test", CredentialDefinitionId = "1", Predicate = ">", Threshold = 99999, Referent = "Proof of Test > $99,999" } }; var(issuerConnection, holderConnection) = await Scenarios.EstablishConnectionAsync( _connectionService, _messages, _issuerWallet, _holderWallet); var proofProposal = new ProofProposal { Comment = "Hello, World", ProposedAttributes = proposedAttributes, ProposedPredicates = proposedPredicates }; var(message, record) = await _proofService.CreateProposalAsync(_holderWallet, proofProposal, holderConnection.Id); var expectedMessage = new ProposePresentationMessage { Id = message.Id, Comment = "Hello, World", PresentationPreviewMessage = new PresentationPreviewMessage { Id = message.PresentationPreviewMessage.Id, ProposedAttributes = proposedAttributes.ToArray(), ProposedPredicates = proposedPredicates.ToArray() } }; message.Should().BeEquivalentTo(expectedMessage); }