Skip to content

Commit

Permalink
add clients deactivation when agreement archive is performed (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
beetlecrunch authored Jul 27, 2023
1 parent 1ccf6ed commit 5aaf608
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,12 @@ final case class AgreementApiServiceImpl(
stamps = agreement.stamps.copy(archiving = AgreementManagement.Stamp(uid, offsetDateTimeSupplier.get()).some)
)
)
_ <- authorizationManagementService.updateStateOnClients(
eServiceId = agreement.eserviceId,
consumerId = agreement.consumerId,
agreementId = agreement.id,
state = AuthorizationManagement.ClientComponentState.INACTIVE
)
} yield agreement

val result: Future[Agreement] = for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest
import it.pagopa.interop.agreementmanagement.client.{model => AgreementManagement}
import it.pagopa.interop.agreementprocess.events.ArchiveEvent
import it.pagopa.interop.agreementprocess.common.Adapters._
import it.pagopa.interop.authorizationmanagement.client.model.ClientComponentState
import org.scalatest.matchers.should.Matchers._
import org.scalatest.wordspec.AnyWordSpecLike

import java.util.UUID
import scala.concurrent.Future

class AgreementArchiviationSpec extends AnyWordSpecLike with SpecHelper with ScalatestRouteTest {

Expand All @@ -31,6 +33,11 @@ class AgreementArchiviationSpec extends AnyWordSpecLike with SpecHelper with Sca
val now = SpecData.when
mockAgreementRetrieve(agreement.toPersistent)
mockAgreementUpdate(agreement.id, expectedSeed, agreement.copy(stamps = SpecData.archiviationStamps))
(mockAuthorizationManagementService
.updateStateOnClients(_: UUID, _: UUID, _: UUID, _: ClientComponentState)(_: Seq[(String, String)]))
.expects(agreement.eserviceId, agreement.consumerId, agreement.id, ClientComponentState.INACTIVE, *)
.once()
.returns(Future.unit)
mockArchiveEventSending(ArchiveEvent(agreement.id, now)).twice()

Get() ~> service.archiveAgreement(agreement.id.toString) ~> check {
Expand Down

0 comments on commit 5aaf608

Please sign in to comment.