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

v2.1-rc2 #379

Merged
merged 3 commits into from
Jun 10, 2020
Merged
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
17 changes: 0 additions & 17 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
@@ -58,23 +58,6 @@ withNightlyPipeline(type, product, component) {

after('fullFunctionalTest') {

sh "./gradlew smoke"

archiveArtifacts '**/build/test-results/**/*'

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "output",
reportFiles : "idam-web-public-e2e-result.html",
reportName : "IDAM Web Public E2E smoke tests result"
]

sh "./gradlew functional"

archiveArtifacts '**/build/test-results/**/*'

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
11 changes: 0 additions & 11 deletions infrastructure/state.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
terraform {
backend "azurerm" {}
}

data "terraform_remote_state" "core-infra" {
backend = "azurerm"

config {
resource_group_name = "mgmt-state-store-${var.subscription}"
storage_account_name = "mgmtstatestore${var.subscription}"
container_name = "mgmtstatestorecontainer${var.env}"
key = "core-infra/${var.env}/terraform.tfstate"
}
}
20 changes: 10 additions & 10 deletions src/main/java/uk/gov/hmcts/reform/idam/web/helper/JSPHelper.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package uk.gov.hmcts.reform.idam.web.helper;

import lombok.NonNull;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.net.URLCodec;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.context.request.RequestContextHolder;
@@ -14,33 +15,32 @@

import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Locale;
import java.util.Optional;

@UtilityClass
public class JSPHelper {

private static final UrlPathHelper PATH_HELPER = new UrlPathHelper();
private static final URLCodec URL_CODEC = new URLCodec();
private static MessageSource messageSource;
private final UrlPathHelper pathHelper = new UrlPathHelper();

/**
* @should return correct url for English
* @should return correct url for Welsh
* @should throw if there is no request in context
*/
@Nonnull
@SneakyThrows(UnsupportedEncodingException.class)
public String getOtherLocaleUrl() {
public String getOtherLocaleUrl() throws DecoderException {
final ServletRequestAttributes servletRequestAttributes = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes());
final HttpServletRequest request = servletRequestAttributes != null ? servletRequestAttributes.getRequest() : null;
final String targetLocale = getTargetLocale();


if (request != null) {
final String requestUri = PATH_HELPER.getOriginatingRequestUri(request);
final String originatingQueryString = PATH_HELPER.getOriginatingQueryString(request);
final String requestQueryString = originatingQueryString == null ? null : URLDecoder.decode(originatingQueryString, "UTF-8"); //NOSONAR
final String requestUri = pathHelper.getOriginatingRequestUri(request);
final String originatingQueryString = pathHelper.getOriginatingQueryString(request);
final String requestQueryString = originatingQueryString == null ? null : URL_CODEC.decode(originatingQueryString); //NOSONAR
final UriComponentsBuilder initialUrl = UriComponentsBuilder.fromPath(requestUri).replaceQuery(requestQueryString);

return overrideLocaleParameter(initialUrl, targetLocale);
@@ -54,9 +54,9 @@ public String getOtherLocaleUrl() {
*
* @should override existing parameter
* @should add nonexisting parameter
* @should throw on any of the parameters being null
*/
public static String overrideLocaleParameter(@NonNull final UriComponentsBuilder builder, @NonNull final String targetLocale) {

return builder.replaceQueryParam(MessagesConfiguration.UI_LOCALES_PARAM_NAME, new Locale(targetLocale)).toUriString();
}

Original file line number Diff line number Diff line change
@@ -56,6 +56,27 @@ public void overrideLocaleParameter_shouldAddNonexistingParameter() {
Assert.assertEquals(CORRECT_BASE_TEST_URI + targetLocale, rewrittenUrl);
}

/**
* @verifies throw on any of the parameters being null
* @see JSPHelper#overrideLocaleParameter(org.springframework.web.util.UriComponentsBuilder, String)
*/
@Test
public void overrideLocaleParameter_shouldThrowOnAnyOfTheParametersBeingNull() {
try {
JSPHelper.overrideLocaleParameter(UriComponentsBuilder.newInstance(), null);
Assert.fail();
} catch (NullPointerException e) {
// do nothing, expected
}

try {
JSPHelper.overrideLocaleParameter(null, "en");
Assert.fail();
} catch (NullPointerException e) {
// do nothing, expected
}
}

/**
* @verifies return en if current locale is welsh
* @see JSPHelper#getTargetLocale()