diff --git a/.travis.yml.disabled b/.travis.yml.disabled deleted file mode 100644 index eb83e3e..0000000 --- a/.travis.yml.disabled +++ /dev/null @@ -1,41 +0,0 @@ -language: java -before_script: - - unset _JAVA_OPTIONS - - cd finish - - chmod +x ../scripts/travisTest.sh -script: - - ../scripts/travisTest.sh -after_script: -- logsPath=$(find . -name "console.log" | sed "s/console.log//g"); -- build=$(grep "Open Liberty" $logsPath/console.log | cut -d" " -f5 | cut -d")" -f1 ); -- release=$( echo "$build" | cut -d'/' -f1); -- number=$(echo "$build" | cut -d'/' -f2); -- ol_jv=$(grep -i "version" $logsPath/console.log); -- jv=$(printf '%s\n' "${ol_jv//$' on '/$'\n'}" | sed '2q;d'); -- echo -e "\n"\ - "\033[1;34m Open Liberty release:\033[0m\033[1;36m $release \033[0m \n"\ - "\033[1;34m Open Liberty build number:\033[0m\033[1;36m $number \033[0m \n"\ - "\033[1;34m Java version:\033[0m\033[1;36m $jv \033[0m \n"; -- cd $logsPath; -- repo_name=$(echo "$TRAVIS_REPO_SLUG" | sed -e "s/\//-/g"); -- if [ "$TRAVIS_TEST_RESULT" -eq 0 ]; then RESULT="passed"; else RESULT="failed"; fi; -- echo -e "\033[1;34m result:\033[0m\033[1;36m $RESULT \033[0m \n" -- serverlogsarchive="$repo_name-$TRAVIS_BUILD_NUMBER-$RESULT.zip"; -- if [ "$TRAVIS_TEST_RESULT" -eq 0 ]; then echo skipped to zip $serverlogsarchive; else zip -r "$serverlogsarchive" .; fi; -- if [ "$TRAVIS_TEST_RESULT" -eq 0 ]; then echo skipped upload; else curl -H "$JFROG_TOKEN" -T "$serverlogsarchive" "https://na.artifactory.swg-devops.com/artifactory/hyc-openliberty-guides-files-generic-local/"; fi; -notifications: - slack: - template: - - 'Build: <%{build_url}| %{build_number}> | Commit (<%{compare_url}|%{commit}>): - %{commit_message}' - - 'Repo@Branch: %{repository_slug}@%{branch}' - - 'Author: %{author}' - - 'Summary: %{result} in %{duration}' - rooms: - secure: YAN9jHT0jPy+owzCsvPQOqbf+EJH0YaMJxtqSJeSq2TmwunOqofHSqD50rLrkwYkh7pPvkW9t/HVT/+2KvNAG0FRjUIEQlJhruYOAR8zT8s38WCqWGa7QbLWHdPa00Abi+sunLFZQ7dvK/z2dgHfoWTpyn6T9qTkin3Bx+vYxzxLtxe1+kCjVOmCjPVLQlDeEJNzWSkDw+vZNPoJLzwKRaf80kcbmn8bjb6G8aGVrlKvjaV2ft34R/P8ysf4ePK92eWVE6y9nzszOs5XK8SdbRN97z2frVExMTzXzIp2uJTxQ5Pm812h2j3rVgyQIGECyhm/m7ACpBoFE+08JvdPb83C2gUgNf4bZWZ00IhXaPk8DMArNgijP+Mjvi9E1v/QMm/34+/nmUmQsw67GJ4lfSTzL3WmRcCjIvb31nKOMoqP35MR+uc2ZG2hcci1TZtK/+PQbAz24yaezyMycnYk5dhW+cltYHHw/uzsArecV0luL6C2MYHtLkJVClgBLo/LIyxcY+GtKoxfN8FNVjw9Djx7SKCDKeuHwf5CFE5BWBs+UbSVTjmmahUS2hfRaLGmo1S9HoZoZULe6HhyqUmRff+YL/BvWr+MPRiwqewt/MBbbLH5XhZAum32JOYa9nf4XV/zWW3wN6JiodRsaO9doi4RE+gRcHR+XDsSFDlclfM= - on_success: never - on_failure: always -branches: - only: - - master - diff --git a/finish/src/main/liberty/config/server.xml b/finish/src/main/liberty/config/server.xml index d7edee4..dbdec6c 100644 --- a/finish/src/main/liberty/config/server.xml +++ b/finish/src/main/liberty/config/server.xml @@ -15,7 +15,7 @@ diff --git a/finish/src/test/java/it/io/openliberty/guides/cors/TestData.java b/finish/src/test/java/it/io/openliberty/guides/cors/TestData.java index f4839e5..7df03b1 100644 --- a/finish/src/test/java/it/io/openliberty/guides/cors/TestData.java +++ b/finish/src/test/java/it/io/openliberty/guides/cors/TestData.java @@ -1,15 +1,14 @@ -// tag::comment[] +// tag::copyright[] /******************************************************************************* - * Copyright (c) 2017 IBM Corporation and others. + * Copyright (c) 2017, 2019 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * http://www.eclipse.org/legal/epl-2.0/ * - * Contributors: - * IBM Corporation - Initial implementation + * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -// end::comment[] +// end::copyright[] package it.io.openliberty.guides.cors; import java.util.HashMap; @@ -17,39 +16,68 @@ public class TestData { - public static String REQUEST_HEADER_ORIGIN = "Origin"; - public static String REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; - public static String REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; + public static String requestHeaderOrigin; + public static String requestHeaderAccessControlRequestMethod; + public static String requestHeaderAccessControlRequestHeaders; + public static String responseHeaderAccessControlAllowOrigin; + public static String responseHeaderAccessControlAllowCredentials; + public static String responseHeaderAccessControlExposeHeaders; + public static String responseHeaderAccessControlMaxAge; + public static String responseHeaderAccessControlAllowMethods; + public static String responseHeaderAccessControlAllowHeaders; + public static Map simpleRequestHeaders; + public static Map simpleResponseHeaders; + public static Map preflightRequestHeaders; + public static Map preflightResponseHeaders; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; + public static String prefix; - public static Map simpleRequestHeaders = new HashMap(); - public static Map simpleResponseHeaders = new HashMap(); + static { - public static Map preflightRequestHeaders = new HashMap(); - public static Map preflightResponseHeaders = new HashMap(); + prefix = "Access-Control-"; - static { - simpleRequestHeaders.put(REQUEST_HEADER_ORIGIN, "openliberty.io"); + requestHeaderOrigin = "Origin"; + requestHeaderAccessControlRequestMethod = prefix + "Request-Method"; + requestHeaderAccessControlRequestHeaders = prefix + "Request-Headers"; + + responseHeaderAccessControlAllowOrigin = prefix + "Allow-Origin"; + responseHeaderAccessControlAllowCredentials = prefix + "Allow-Credentials"; + responseHeaderAccessControlExposeHeaders = prefix + "Expose-Headers"; + responseHeaderAccessControlMaxAge = prefix + "Max-Age"; + responseHeaderAccessControlAllowMethods = prefix + "Allow-Methods"; + responseHeaderAccessControlAllowHeaders = prefix + "Allow-Headers"; + + simpleRequestHeaders = new HashMap(); + simpleResponseHeaders = new HashMap(); + + preflightRequestHeaders = new HashMap(); + preflightResponseHeaders = new HashMap(); + + + simpleRequestHeaders.put(requestHeaderOrigin, "http://openliberty.io"); - simpleResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "openliberty.io"); - simpleResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); - simpleResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS, "MyHeader"); + simpleResponseHeaders.put(responseHeaderAccessControlAllowOrigin, + "http://openliberty.io"); + simpleResponseHeaders.put(responseHeaderAccessControlAllowCredentials, + "true"); + simpleResponseHeaders.put(responseHeaderAccessControlExposeHeaders, + "MyHeader"); - preflightRequestHeaders.put(REQUEST_HEADER_ORIGIN, "anywebsiteyoulike.com"); - preflightRequestHeaders.put(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD, "DELETE"); - preflightRequestHeaders.put(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS, "MyOwnHeader2"); + preflightRequestHeaders.put(requestHeaderOrigin, "anywebsiteyoulike.com"); + preflightRequestHeaders.put(requestHeaderAccessControlRequestMethod, + "DELETE"); + preflightRequestHeaders.put(requestHeaderAccessControlRequestHeaders, + "MyOwnHeader2"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "anywebsiteyoulike.com"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE, "10"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS, "OPTIONS, DELETE"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS, "MyOwnHeader1, MyOwnHeader2"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowOrigin, + "anywebsiteyoulike.com"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowCredentials, + "true"); + preflightResponseHeaders.put(responseHeaderAccessControlMaxAge, "10"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowMethods, + "OPTIONS, DELETE"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowHeaders, + "MyOwnHeader1, MyOwnHeader2"); } } diff --git a/start/src/test/java/it/io/openliberty/guides/cors/TestData.java b/start/src/test/java/it/io/openliberty/guides/cors/TestData.java index f4839e5..7df03b1 100644 --- a/start/src/test/java/it/io/openliberty/guides/cors/TestData.java +++ b/start/src/test/java/it/io/openliberty/guides/cors/TestData.java @@ -1,15 +1,14 @@ -// tag::comment[] +// tag::copyright[] /******************************************************************************* - * Copyright (c) 2017 IBM Corporation and others. + * Copyright (c) 2017, 2019 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * http://www.eclipse.org/legal/epl-2.0/ * - * Contributors: - * IBM Corporation - Initial implementation + * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ -// end::comment[] +// end::copyright[] package it.io.openliberty.guides.cors; import java.util.HashMap; @@ -17,39 +16,68 @@ public class TestData { - public static String REQUEST_HEADER_ORIGIN = "Origin"; - public static String REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"; - public static String REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"; + public static String requestHeaderOrigin; + public static String requestHeaderAccessControlRequestMethod; + public static String requestHeaderAccessControlRequestHeaders; + public static String responseHeaderAccessControlAllowOrigin; + public static String responseHeaderAccessControlAllowCredentials; + public static String responseHeaderAccessControlExposeHeaders; + public static String responseHeaderAccessControlMaxAge; + public static String responseHeaderAccessControlAllowMethods; + public static String responseHeaderAccessControlAllowHeaders; + public static Map simpleRequestHeaders; + public static Map simpleResponseHeaders; + public static Map preflightRequestHeaders; + public static Map preflightResponseHeaders; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods"; - public static String RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"; + public static String prefix; - public static Map simpleRequestHeaders = new HashMap(); - public static Map simpleResponseHeaders = new HashMap(); + static { - public static Map preflightRequestHeaders = new HashMap(); - public static Map preflightResponseHeaders = new HashMap(); + prefix = "Access-Control-"; - static { - simpleRequestHeaders.put(REQUEST_HEADER_ORIGIN, "openliberty.io"); + requestHeaderOrigin = "Origin"; + requestHeaderAccessControlRequestMethod = prefix + "Request-Method"; + requestHeaderAccessControlRequestHeaders = prefix + "Request-Headers"; + + responseHeaderAccessControlAllowOrigin = prefix + "Allow-Origin"; + responseHeaderAccessControlAllowCredentials = prefix + "Allow-Credentials"; + responseHeaderAccessControlExposeHeaders = prefix + "Expose-Headers"; + responseHeaderAccessControlMaxAge = prefix + "Max-Age"; + responseHeaderAccessControlAllowMethods = prefix + "Allow-Methods"; + responseHeaderAccessControlAllowHeaders = prefix + "Allow-Headers"; + + simpleRequestHeaders = new HashMap(); + simpleResponseHeaders = new HashMap(); + + preflightRequestHeaders = new HashMap(); + preflightResponseHeaders = new HashMap(); + + + simpleRequestHeaders.put(requestHeaderOrigin, "http://openliberty.io"); - simpleResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "openliberty.io"); - simpleResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); - simpleResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS, "MyHeader"); + simpleResponseHeaders.put(responseHeaderAccessControlAllowOrigin, + "http://openliberty.io"); + simpleResponseHeaders.put(responseHeaderAccessControlAllowCredentials, + "true"); + simpleResponseHeaders.put(responseHeaderAccessControlExposeHeaders, + "MyHeader"); - preflightRequestHeaders.put(REQUEST_HEADER_ORIGIN, "anywebsiteyoulike.com"); - preflightRequestHeaders.put(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD, "DELETE"); - preflightRequestHeaders.put(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS, "MyOwnHeader2"); + preflightRequestHeaders.put(requestHeaderOrigin, "anywebsiteyoulike.com"); + preflightRequestHeaders.put(requestHeaderAccessControlRequestMethod, + "DELETE"); + preflightRequestHeaders.put(requestHeaderAccessControlRequestHeaders, + "MyOwnHeader2"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "anywebsiteyoulike.com"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE, "10"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS, "OPTIONS, DELETE"); - preflightResponseHeaders.put(RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS, "MyOwnHeader1, MyOwnHeader2"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowOrigin, + "anywebsiteyoulike.com"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowCredentials, + "true"); + preflightResponseHeaders.put(responseHeaderAccessControlMaxAge, "10"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowMethods, + "OPTIONS, DELETE"); + preflightResponseHeaders.put(responseHeaderAccessControlAllowHeaders, + "MyOwnHeader1, MyOwnHeader2"); } }