Skip to content

Commit

Permalink
Merge pull request #951 from hmrc/BDOG-3261
Browse files Browse the repository at this point in the history
BDOG-3261: Feature flag create user pages
  • Loading branch information
BriWak authored Sep 25, 2024
2 parents 250052c + cd1c276 commit 8eebec6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@

package uk.gov.hmrc.cataloguefrontend.config

import play.api.Configuration
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig

import javax.inject.{Inject, Singleton}

@Singleton
class CatalogueConfig @Inject() (servicesConfig: ServicesConfig):
class CatalogueConfig @Inject() (configuration: Configuration, servicesConfig: ServicesConfig):
def killSwitchLink(shutterType: String): String =
servicesConfig.getString(s"killswitch.jenkins-job.$shutterType")

val showCreateUserJourney: Boolean =
configuration.get[Boolean]("feature.show-create-user-journey")
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import cats.data.EitherT
import play.api.Logger
import play.api.data.{Form, Forms}
import play.api.data.validation.{Constraint, Constraints, Invalid, Valid}
import play.api.mvc._
import play.api.mvc.*
import uk.gov.hmrc.cataloguefrontend.auth.CatalogueAuthBuilders
import uk.gov.hmrc.cataloguefrontend.config.CatalogueConfig
import uk.gov.hmrc.cataloguefrontend.connector.UserManagementConnector
import uk.gov.hmrc.cataloguefrontend.model.TeamName
import uk.gov.hmrc.cataloguefrontend.users.view.html.{CreateUserPage, CreateUserRequestSentPage}
import uk.gov.hmrc.internalauth.client._
import uk.gov.hmrc.cataloguefrontend.view.html.error_404_template
import uk.gov.hmrc.internalauth.client.*
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendController

import javax.inject.{Inject, Singleton}
Expand All @@ -35,6 +37,7 @@ import scala.concurrent.{ExecutionContext, Future}
class CreateUserController @Inject()(
override val auth : FrontendAuthComponents,
override val mcc : MessagesControllerComponents,
config : CatalogueConfig,
createUserPage : CreateUserPage,
createUserRequestSentPage: CreateUserRequestSentPage,
userManagementConnector : UserManagementConnector
Expand All @@ -59,7 +62,10 @@ class CreateUserController @Inject()(
continueUrl = routes.CreateUserController.createUserLanding(isServiceAccount),
retrieval = Retrieval.locations(resourceType = Some(ResourceType("catalogue-frontend")), action = Some(IAAction("CREATE_USER")))
).apply { implicit request =>
Ok(createUserPage(CreateUserForm.form, cleanseUserTeams(request.retrieval), Organisation.values.toSeq, isServiceAccount))
if config.showCreateUserJourney then
Ok(createUserPage(CreateUserForm.form, cleanseUserTeams(request.retrieval), Organisation.values.toSeq, isServiceAccount))
else
NotFound(error_404_template())
}

def createUser(isServiceAccount: Boolean): Action[AnyContent] =
Expand Down
5 changes: 4 additions & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,7 @@ bootstrap.auditfilter.maskedFormFields = [ "password" ]
# B&D api for create app configs does not support externaltest
environmentsToHideByDefault = ["integration", "development", "externaltest"]

feature.show-decommission-button = false
feature {
show-decommission-button = false
show-create-user-journey = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.cataloguefrontend.createuser

import org.mockito.ArgumentMatchers.{any, eq => eqTo}
import org.mockito.ArgumentMatchers.{any, eq as eqTo}
import org.mockito.Mockito.when
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.matchers.should.Matchers
Expand All @@ -25,14 +25,15 @@ import org.scalatestplus.mockito.MockitoSugar
import play.api.mvc.MessagesControllerComponents
import play.api.test.FakeRequest
import play.api.test.Helpers.{POST, contentAsString, defaultAwaitTimeout, redirectLocation, status}
import uk.gov.hmrc.cataloguefrontend.config.CatalogueConfig
import uk.gov.hmrc.cataloguefrontend.test.FakeApplicationBuilder
import uk.gov.hmrc.cataloguefrontend.connector.UserManagementConnector
import uk.gov.hmrc.cataloguefrontend.model.TeamName
import uk.gov.hmrc.cataloguefrontend.users.{CreateUserController, CreateUserRequest, Organisation, routes}
import uk.gov.hmrc.cataloguefrontend.users.view.html.{CreateUserPage, CreateUserRequestSentPage}
import uk.gov.hmrc.http.{HeaderCarrier, SessionKeys}
import uk.gov.hmrc.internalauth.client.test.{FrontendAuthComponentsStub, StubBehaviour}
import uk.gov.hmrc.internalauth.client._
import uk.gov.hmrc.internalauth.client.*

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
Expand Down Expand Up @@ -195,14 +196,18 @@ class CreateUserControllerSpec

val mockCUPView : CreateUserPage = app.injector.instanceOf[CreateUserPage]
val mockCURSPView : CreateUserRequestSentPage = app.injector.instanceOf[CreateUserRequestSentPage]
val mockConfig : CatalogueConfig = mock[CatalogueConfig]
val mockUMConnector : UserManagementConnector = mock[UserManagementConnector]
val authStubBehaviour: StubBehaviour = mock[StubBehaviour]
val authComponent : FrontendAuthComponents = FrontendAuthComponentsStub(authStubBehaviour)

when(mockConfig.showCreateUserJourney).thenReturn(true)

val controller =
CreateUserController(
auth = authComponent,
mcc = mcc,
config = mockConfig,
createUserPage = mockCUPView,
createUserRequestSentPage = mockCURSPView,
userManagementConnector = mockUMConnector
Expand Down

0 comments on commit 8eebec6

Please sign in to comment.