/* * The MIT License * * Original work sponsored and donated by National Board of e-Health (NSI), Denmark (http://www.nsi.dk) * * Copyright (C) 2011 National Board of e-Health (NSI), Denmark (http://www.nsi.dk) * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * $HeadURL$ * $Id$ */ package com.trifork.sosigw.ws; import static org.junit.Assert.*; import java.util.Map; import com.trifork.sosigw.Factory; import com.trifork.sosigw.cluster.IDCardClusterCacheImpl; import com.trifork.sosigw.testclient.ServiceStubClient; import org.junit.Before; import org.junit.Test; import org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0.Security; /** * Test that NSP HTTP Headers are correctly added or passed on to backend service * */ public class NspHttpHeadersOnProxyTest extends AbstractIntegrationTests { @Before public void cleanCache() { Factory.setTheIDCardCache(new IDCardClusterCacheImpl(null)); } @Test public void testNspProxyHeadersAreAdded() throws Exception { createSignedIdCard(); Security securityHeader = IdCardTestUtils.makeIDCardInSecurity(); ServiceStubClient client = new ServiceStubClient("localhost:8586", true, true, true, true, false); client.doInvoke(null, securityHeader, "", 0, 0, SERVER_URL + "/proxy/soap-request", false); Map headers = getHttpRequestHeaders(); assertTrue(headers.get("X_NSP_FLOWID").length() > 0); assertTrue(headers.get("X_NSP_PROXY_REQUESTID").length() > 0); } @Test public void testNspOptionalNspProxyHeadersAreAdded() throws Exception { createSignedIdCard(); Security securityHeader = IdCardTestUtils.makeIDCardInSecurity(); ServiceStubClient client = new ServiceStubClient("localhost:8586", true, true, true, true, false); client.doInvoke(null, securityHeader, "", 0, 0, SERVER_URL + "/proxy/soap-request", false); Map headers = getHttpRequestHeaders(); assertEquals(headers.get("X_NSP_MY_HTTP_FORWARD_HEADER1"), "optional_header1"); assertEquals(headers.get("X_NSP_MY_HTTP_FORWARD_HEADER2"), "optional_header2"); } }