Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSET-2023 hide create an account once the campaign is closed #88

Merged
merged 2 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/views/govuk_template.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*@

@(title: String, user: Option[CachedData] = None, additionalJavascriptFilenames: List[String] = Nil)(mainContent: Html)(implicit request: Request[_], feedbackUrl: String)
@(title: String, user: Option[CachedData] = None, additionalJavascriptFilenames: List[String] = Nil, campaignClosed: Boolean = false)(mainContent: Html)(implicit request: Request[_], feedbackUrl: String)

@import config.FrontendAppConfig
@import views.html.template.userDetails
Expand Down Expand Up @@ -97,7 +97,7 @@
</div>
</div>
<div class="grid grid-1-3">
@userDetails(user)
@userDetails(user, campaignClosed)
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/index/guestwelcome.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@import helpers.CSRFieldConstructor._
@import play.filters.csrf.CSRF

@main_template(title = "Create your account or Sign in", pageForms = Seq(signInForm), notification = notification) {
@main_template(title = "Create your account or Sign in", pageForms = Seq(signInForm), notification = notification, campaignClosed = !fasttrackConfig.newAccountsEnabled) {

<h1 class="heading-xlarge">Sign in</h1>
@if(fasttrackConfig.newAccountsEnabled) {
Expand Down
4 changes: 2 additions & 2 deletions app/views/main_template.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*@

@(title: String, pageForms: Seq[Form[_]] = Nil, notification: Option[(helpers.NotificationType,String)] = None, additionalJavascriptFilenames: List[String] = Nil)(mainContent: Html)(implicit request: Request[_], flash: Flash, user: Option[CachedData], feedbackUrl: String, messages: Messages)
@(title: String, pageForms: Seq[Form[_]] = Nil, notification: Option[(helpers.NotificationType,String)] = None, additionalJavascriptFilenames: List[String] = Nil, campaignClosed: Boolean = false)(mainContent: Html)(implicit request: Request[_], flash: Flash, user: Option[CachedData], feedbackUrl: String, messages: Messages)

@import views.html.template.{ errorSummary, flashMessage }

@govuk_template(title = title, user = user, additionalJavascriptFilenames = additionalJavascriptFilenames) {
@govuk_template(title = title, user = user, additionalJavascriptFilenames = additionalJavascriptFilenames, campaignClosed = campaignClosed) {
@flashMessage(notification)
@errorSummary(pageForms)
@mainContent
Expand Down
8 changes: 6 additions & 2 deletions app/views/template/userDetails.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*@

@(user: Option[CachedData])(implicit request: Request[_])
@(user: Option[CachedData], campaignClosed: Boolean)(implicit request: Request[_])

@user.map { data =>
<div class="account-info sign-out" id="bannerSignedIn">
Expand All @@ -37,7 +37,11 @@
}.getOrElse {
<div class="account-info sign-in">
<div class="small-btm-margin">
<a href="@routes.SignUpController.signUp()"><i class="fa fa-sign-in"></i>Create an account</a> or <a href="@routes.SignInController.present()">Sign in</a>
@if(campaignClosed) {
<a href="@routes.SignInController.present()">Sign in</a>
} else {
<a href="@routes.SignUpController.signUp()"><i class="fa fa-sign-in"></i>Create an account</a> or <a href="@routes.SignInController.present()">Sign in</a>
}
</div>
</div>
}
5 changes: 5 additions & 0 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
digital-service: "FSET: Fasttrack"

leakDetectionExemptions:
- ruleId: 'ip_addresses'
filePaths:
- '/test/config/WhitelistFilterConfigSpec.scala'
13 changes: 8 additions & 5 deletions test/config/WhitelistFilterConfigSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ import play.api.test._

class WhitelistFilterConfigSpec extends PlaySpec with OneAppPerTest {

val dummyIP1 = "11.22.33.44"
val dummyIP2 = "93.00.33.33"

override def newAppForTest(td: TestData): FakeApplication =
FakeApplication(
additionalConfiguration = Map(
"whitelistExcludedCalls" -> Base64.getEncoder.encodeToString("/ping/ping,/healthcheck".getBytes),
"whitelist" -> Base64.getEncoder.encodeToString("11.22.33.44".getBytes)
"whitelist" -> Base64.getEncoder.encodeToString(dummyIP1.getBytes)
),
withGlobal = Some(ProductionFrontendGlobal)
)
Expand All @@ -40,30 +43,30 @@ class WhitelistFilterConfigSpec extends PlaySpec with OneAppPerTest {
FrontendAppConfig.whitelistExcluded mustBe Seq("/ping/ping", "/healthcheck")
}
"the whitelist IPs are requested" in {
FrontendAppConfig.whitelist mustBe Seq("11.22.33.44")
FrontendAppConfig.whitelist mustBe Seq(dummyIP1)
}
}
}

"ProductionFrontendGlobal" must {
"let requests passing" when {
"coming from an IP in the white list must work as normal" in {
val request = FakeRequest(GET, "/fset-fast-track/signin").withHeaders("True-Client-IP" -> "11.22.33.44")
val request = FakeRequest(GET, "/fset-fast-track/signin").withHeaders("True-Client-IP" -> dummyIP1)
val Some(result) = route(app, request)

status(result) mustBe OK
}

"coming from a IP NOT in the white-list and not with a white-listed path must be redirected" in {
val request = FakeRequest(GET, "/fset-fast-track/signin").withHeaders("True-Client-IP" -> "93.00.33.33")
val request = FakeRequest(GET, "/fset-fast-track/signin").withHeaders("True-Client-IP" -> dummyIP2)
val Some(result) = route(app, request)

status(result) mustBe SEE_OTHER
redirectLocation(result) mustBe Some("https://www.apply-civil-service-apprenticeship.service.gov.uk/shutter/fset-fasttrack/index.html")
}

"coming from an IP NOT in the white-list, but with a white-listed path must work as normal" in {
val request = FakeRequest(GET, "/ping/ping").withHeaders("True-Client-IP" -> "93.00.33.33")
val request = FakeRequest(GET, "/ping/ping").withHeaders("True-Client-IP" -> dummyIP2)
val Some(result) = route(app, request)

status(result) mustBe OK
Expand Down