From b73b8066651f0685fd8b2fd46b1e12d4adfe4156 Mon Sep 17 00:00:00 2001 From: Shailesh Patil <53746241+mineme0110@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:36:46 +0100 Subject: [PATCH] fix: delete subject id from presentation record (#1314) Signed-off-by: mineme0110 --- .../server/jobs/PresentBackgroundJobs.scala | 33 ++++--------------- .../core/model/PresentationRecord.scala | 4 --- .../service/PresentationServiceImpl.scala | 3 -- .../PresentationRepositorySpecSuite.scala | 1 - .../PresentationServiceNotifierSpec.scala | 1 - ..._subject_id_column_presentation_record.sql | 4 +++ .../JdbcPresentationRepository.scala | 7 ---- 7 files changed, 11 insertions(+), 42 deletions(-) create mode 100644 pollux/sql-doobie/src/main/resources/sql/pollux/V26__remove_subject_id_column_presentation_record.sql diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala index 0bf8f7fb61..85106e084f 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/PresentBackgroundJobs.scala @@ -106,7 +106,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, InvitationGenerated, _, _, @@ -124,15 +123,15 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _ ) => ZIO.unit - case PresentationRecord(_, _, _, _, _, _, _, _, InvitationExpired, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(_, _, _, _, _, _, _, InvitationExpired, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.unit - case PresentationRecord(id, _, _, _, _, _, _, _, ProposalPending, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(id, _, _, _, _, _, _, ProposalPending, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.fail(NotImplemented) - case PresentationRecord(id, _, _, _, _, _, _, _, ProposalSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(id, _, _, _, _, _, _, ProposalSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.fail(NotImplemented) - case PresentationRecord(id, _, _, _, _, _, _, _, ProposalReceived, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(id, _, _, _, _, _, _, ProposalReceived, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.fail(NotImplemented) - case PresentationRecord(id, _, _, _, _, _, _, _, ProposalRejected, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(id, _, _, _, _, _, _, ProposalRejected, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.fail(NotImplemented) case PresentationRecord( id, @@ -142,7 +141,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, RequestPending, _, _, @@ -168,7 +166,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, RequestPending, _, _, @@ -194,7 +191,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, RequestSent, _, _, @@ -220,7 +216,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, RequestReceived, _, _, @@ -246,7 +241,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, RequestRejected, _, _, @@ -272,7 +266,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, ProblemReportPending, _, _, @@ -290,7 +283,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _ ) => ZIO.fail(NotImplemented) - case PresentationRecord(id, _, _, _, _, _, _, _, ProblemReportSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(id, _, _, _, _, _, _, ProblemReportSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.fail(NotImplemented) case PresentationRecord( id, @@ -300,7 +293,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, ProblemReportReceived, _, _, @@ -326,7 +318,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationPending, _, _, @@ -353,7 +344,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationPending, credentialFormat, _, @@ -386,7 +376,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationGenerated, _, _, @@ -413,7 +402,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationGenerated, _, _, @@ -433,7 +421,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { ZIO.logDebug("PresentationRecord: PresentationGenerated") *> ZIO.unit Prover.handlePresentationGenerated(id, presentation) - case PresentationRecord(id, _, _, _, _, _, _, _, PresentationSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case PresentationRecord(id, _, _, _, _, _, _, PresentationSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => ZIO.logDebug("PresentationRecord: PresentationSent") *> ZIO.unit case PresentationRecord( id, @@ -443,7 +431,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationReceived, _, _, @@ -469,7 +456,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationReceived, _, _, @@ -495,7 +481,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationReceived, credentialFormat, invitation, @@ -523,7 +508,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationVerificationFailed, _, _, @@ -549,7 +533,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationAccepted, _, _, @@ -575,7 +558,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationVerified, _, _, @@ -601,7 +583,6 @@ object PresentBackgroundJobs extends BackgroundJobsHelper { _, _, _, - _, PresentationRejected, _, _, diff --git a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/model/PresentationRecord.scala b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/model/PresentationRecord.scala index 47993a370b..88c03788de 100644 --- a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/model/PresentationRecord.scala +++ b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/model/PresentationRecord.scala @@ -1,6 +1,5 @@ package org.hyperledger.identus.pollux.core.model -import org.hyperledger.identus.mercury.model.DidId import org.hyperledger.identus.mercury.protocol.invitation.v2.Invitation import org.hyperledger.identus.mercury.protocol.presentproof.{Presentation, ProposePresentation, RequestPresentation} import org.hyperledger.identus.shared.models.{Failure, WalletAccessContext, WalletId} @@ -20,7 +19,6 @@ final case class PresentationRecord( schemaId: Option[String], connectionId: Option[String], role: PresentationRecord.Role, - subjectId: DidId, // TODO Remove protocolState: PresentationRecord.ProtocolState, credentialFormat: CredentialFormat, invitation: Option[Invitation], @@ -55,7 +53,6 @@ object PresentationRecord { schemaId: Option[String], connectionId: Option[String], role: Role, - subjectId: DidId, protocolState: ProtocolState, credentialFormat: CredentialFormat, invitation: Option[Invitation], @@ -80,7 +77,6 @@ object PresentationRecord { schemaId, connectionId, role, - subjectId, protocolState, credentialFormat, invitation, diff --git a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceImpl.scala b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceImpl.scala index 3e8c8a5784..48afbdfa78 100644 --- a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceImpl.scala +++ b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceImpl.scala @@ -421,7 +421,6 @@ private class PresentationServiceImpl( connectionId = connectionId, schemaId = None, // TODO REMOVE from DB role = PresentationRecord.Role.Verifier, - subjectId = pairwiseProverDID.getOrElse(DidId("TODO REMOVE")), // TODO REMOVE from DB protocolState = invitation.fold(PresentationRecord.ProtocolState.RequestPending)(_ => PresentationRecord.ProtocolState.InvitationGenerated ), @@ -499,8 +498,6 @@ private class PresentationServiceImpl( connectionId = connectionId, schemaId = None, role = Role.Prover, - subjectId = - request.to.getOrElse(throw RuntimeException(s"RequestPresentation from field is missing")), // TODO REMOVE protocolState = PresentationRecord.ProtocolState.RequestReceived, credentialFormat = format, invitation = None, diff --git a/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/repository/PresentationRepositorySpecSuite.scala b/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/repository/PresentationRepositorySpecSuite.scala index 5ebfe3233e..3491c070db 100644 --- a/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/repository/PresentationRepositorySpecSuite.scala +++ b/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/repository/PresentationRepositorySpecSuite.scala @@ -25,7 +25,6 @@ object PresentationRepositorySpecSuite { schemaId = None, connectionId = None, role = PresentationRecord.Role.Verifier, - subjectId = DidId("did:prism:aaa"), protocolState = PresentationRecord.ProtocolState.RequestPending, credentialFormat = CredentialFormat.JWT, invitation = None, diff --git a/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceNotifierSpec.scala b/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceNotifierSpec.scala index d76a00d35c..eeb66d593d 100644 --- a/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceNotifierSpec.scala +++ b/pollux/core/src/test/scala/org/hyperledger/identus/pollux/core/service/PresentationServiceNotifierSpec.scala @@ -28,7 +28,6 @@ object PresentationServiceNotifierSpec extends ZIOSpecDefault with PresentationS None, None, PresentationRecord.Role.Verifier, - DidId(""), ProtocolState.RequestPending, CredentialFormat.JWT, None, diff --git a/pollux/sql-doobie/src/main/resources/sql/pollux/V26__remove_subject_id_column_presentation_record.sql b/pollux/sql-doobie/src/main/resources/sql/pollux/V26__remove_subject_id_column_presentation_record.sql new file mode 100644 index 0000000000..31d7ad010c --- /dev/null +++ b/pollux/sql-doobie/src/main/resources/sql/pollux/V26__remove_subject_id_column_presentation_record.sql @@ -0,0 +1,4 @@ +-- presentation_records +-- Remove subject_id column +ALTER TABLE public.presentation_records + DROP COLUMN "subject_id"; \ No newline at end of file diff --git a/pollux/sql-doobie/src/main/scala/org/hyperledger/identus/pollux/sql/repository/JdbcPresentationRepository.scala b/pollux/sql-doobie/src/main/scala/org/hyperledger/identus/pollux/sql/repository/JdbcPresentationRepository.scala index 1a4a962d3a..d91de29b62 100644 --- a/pollux/sql-doobie/src/main/scala/org/hyperledger/identus/pollux/sql/repository/JdbcPresentationRepository.scala +++ b/pollux/sql-doobie/src/main/scala/org/hyperledger/identus/pollux/sql/repository/JdbcPresentationRepository.scala @@ -184,7 +184,6 @@ class JdbcPresentationRepository( | connection_id, | schema_id, | role, - | subject_id, | protocol_state, | credential_format, | invitation, @@ -206,7 +205,6 @@ class JdbcPresentationRepository( | ${record.connectionId}, | ${record.schemaId}, | ${record.role}, - | ${record.subjectId}, | ${record.protocolState}, | ${record.credentialFormat}, | ${record.invitation}, @@ -244,7 +242,6 @@ class JdbcPresentationRepository( | schema_id, | connection_id, | role, - | subject_id, | protocol_state, | credential_format, | invitation, @@ -297,7 +294,6 @@ class JdbcPresentationRepository( | schema_id, | connection_id, | role, - | subject_id, | protocol_state, | credential_format, | invitation, @@ -347,7 +343,6 @@ class JdbcPresentationRepository( | schema_id, | connection_id, | role, - | subject_id, | protocol_state, | credential_format, | invitation, @@ -386,7 +381,6 @@ class JdbcPresentationRepository( | schema_id, | connection_id, | role, - | subject_id, | protocol_state, | credential_format, | invitation, @@ -423,7 +417,6 @@ class JdbcPresentationRepository( | schema_id, | connection_id, | role, - | subject_id, | protocol_state, | credential_format, | invitation,