From c1694a27918ad540c8c18f4eddd00eafd76c679d Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Tue, 21 Oct 2014 09:05:24 -0400 Subject: [PATCH] more saml unit tests --- ...tBindingTest.java => SamlBindingTest.java} | 47 ++++++++++++++++-- .../saml/encrypted-post/WEB-INF/keystore.jks | Bin 0 -> 1707 bytes .../encrypted-post/WEB-INF/picketlink.xml | 31 ++++++++++++ .../saml/signed-get/WEB-INF/keystore.jks | Bin 0 -> 1701 bytes .../saml/signed-get/WEB-INF/picketlink.xml | 36 ++++++++++++++ .../saml/simple-get/WEB-INF/picketlink.xml | 20 ++++++++ .../saml/simple-post/WEB-INF/picketlink.xml | 20 ++++++++ 7 files changed, 149 insertions(+), 5 deletions(-) rename testsuite/integration/src/test/java/org/keycloak/testsuite/saml/{SamlSignedPostBindingTest.java => SamlBindingTest.java} (50%) create mode 100755 testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/keystore.jks create mode 100755 testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/picketlink.xml create mode 100755 testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/keystore.jks create mode 100755 testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/picketlink.xml create mode 100755 testsuite/integration/src/test/resources/saml/simple-get/WEB-INF/picketlink.xml create mode 100755 testsuite/integration/src/test/resources/saml/simple-post/WEB-INF/picketlink.xml diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlSignedPostBindingTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java similarity index 50% rename from testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlSignedPostBindingTest.java rename to testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java index 87d5db7bcf..2700d0f3cf 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlSignedPostBindingTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/saml/SamlBindingTest.java @@ -14,17 +14,20 @@ import org.openqa.selenium.WebDriver; * @author Bill Burke * @version $Revision: 1 $ */ -public class SamlSignedPostBindingTest { +public class SamlBindingTest { @ClassRule public static SamlKeycloakRule keycloakRule = new SamlKeycloakRule() { @Override public void initWars() { - ClassLoader classLoader = SamlSignedPostBindingTest.class.getClassLoader(); + ClassLoader classLoader = SamlBindingTest.class.getClassLoader(); + initializeSamlSecuredWar("/saml/simple-post", "/sales-post", "post.war", classLoader); initializeSamlSecuredWar("/saml/signed-post", "/sales-post-sig", "post-sig.war", classLoader); + initializeSamlSecuredWar("/saml/signed-get", "/employee-sig", "employee-sig.war", classLoader); initializeSamlSecuredWar("/saml/bad-client-signed-post", "/bad-client-sales-post-sig", "bad-client-post-sig.war", classLoader); initializeSamlSecuredWar("/saml/bad-realm-signed-post", "/bad-realm-sales-post-sig", "bad-realm-post-sig.war", classLoader); + initializeSamlSecuredWar("/saml/encrypted-post", "/sales-post-enc", "post-enc.war", classLoader); } @@ -49,7 +52,18 @@ public class SamlSignedPostBindingTest { @Test - public void testSignedLoginLogout() { + public void testPostSimpleLoginLogout() { + driver.navigate().to("http://localhost:8081/sales-post/"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); + loginPage.login("bburke", "password"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/sales-post/"); + Assert.assertTrue(driver.getPageSource().contains("bburke")); + driver.navigate().to("http://localhost:8081/sales-post?GLO=true"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); + + } + @Test + public void testPostSignedLoginLogout() { driver.navigate().to("http://localhost:8081/sales-post-sig/"); Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); loginPage.login("bburke", "password"); @@ -60,7 +74,30 @@ public class SamlSignedPostBindingTest { } @Test - public void testBadClientSignature() { + public void testRedirectSignedLoginLogout() { + driver.navigate().to("http://localhost:8081/employee-sig/"); + Assert.assertTrue(driver.getCurrentUrl().startsWith("http://localhost:8081/auth/realms/demo/protocol/saml")); + loginPage.login("bburke", "password"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/employee-sig/"); + Assert.assertTrue(driver.getPageSource().contains("bburke")); + driver.navigate().to("http://localhost:8081/employee-sig?GLO=true"); + Assert.assertTrue(driver.getCurrentUrl().startsWith("http://localhost:8081/auth/realms/demo/protocol/saml")); + + } + + @Test + public void testPostEncryptedLoginLogout() { + driver.navigate().to("http://localhost:8081/sales-post-enc/"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); + loginPage.login("bburke", "password"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/sales-post-enc/"); + Assert.assertTrue(driver.getPageSource().contains("bburke")); + driver.navigate().to("http://localhost:8081/sales-post-enc?GLO=true"); + Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); + + } + @Test + public void testPostBadClientSignature() { driver.navigate().to("http://localhost:8081/bad-client-sales-post-sig/"); Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); Assert.assertEquals(driver.getTitle(), "We're sorry..."); @@ -68,7 +105,7 @@ public class SamlSignedPostBindingTest { } @Test - public void testBadRealmSignature() { + public void testPostBadRealmSignature() { driver.navigate().to("http://localhost:8081/bad-realm-sales-post-sig/"); Assert.assertEquals(driver.getCurrentUrl(), "http://localhost:8081/auth/realms/demo/protocol/saml"); loginPage.login("bburke", "password"); diff --git a/testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/keystore.jks b/testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/keystore.jks new file mode 100755 index 0000000000000000000000000000000000000000..822162ceafcff816168fc3f807f89fd92b3a5b50 GIT binary patch literal 1707 zcmezO_TO6u1_mZ5W@J#!C@Cqh($~+)PfpCq$S*FjvM{hP&@WERNiEhb0P=NH^OE%$ z7#KYz6Cck2>fCM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HTJiyvVW5 zru?pR{_i>e0}k$(tnC;r5oa2-Tz}z$Rl!j?$69MXo#%*GVPaaoN$;=8DZBZLmV5R~ zRC>-U{#CZmc$=BE5M#KQAhT%8+^_n$VvLhZT`uC}-UE*l?{^AlWvh6deKg5YY<{so z^Q;Vw9PO7U<@L_LnB4EW+5EY0g8J|5$c6=1gidY{vHttw(t18eyGrhp*H{h&Mm|5) z%XjibrSU~}U-!N`MaQ7}%Tf>4p1ZBL@64UmmXiN}_-uXncfFnNCXPLmB^?rPC~tmt e?8L6K8&o7B!`iO)afL5ud@^C)tPg?}*4Y3Vufd)G literal 0 HcmV?d00001 diff --git a/testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/picketlink.xml b/testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/picketlink.xml new file mode 100755 index 0000000000..068d3ecfe5 --- /dev/null +++ b/testsuite/integration/src/test/resources/saml/encrypted-post/WEB-INF/picketlink.xml @@ -0,0 +1,31 @@ + + + ${idp-sig.url::http://localhost:8081/auth/realms/demo/protocol/saml} + + ${sales-post-sig.url::http://localhost:8081/sales-post-enc/} + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/keystore.jks b/testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/keystore.jks new file mode 100755 index 0000000000000000000000000000000000000000..4daad218a3f78b798d1de8996c39014785c45c95 GIT binary patch literal 1701 zcmezO_TO6u1_mZ5W@J##C@Cqh($~+)PfpCq$S*FjvM{hP&`-@R$jPrvP1P;VOxI^% zVDyw<_*fUHZ?{1c({=+sHZE;8MixdbCP79uyORg)YY z9JblVoe37#<8yv++uHrwMt(`Nphxp#7ED_>S+vq3A$V?CM$x=F8~<1CpSc$wm(+Hu zz411`BD+=kz1b=gKRL;#`#Nn7@#d5Jgp zyU+bqJSg}`^iOo zwxaAnwr1v=(`8HSvI0&q#(LVmKj`48_o=|ZF~sUz-)ZfXQ}aKUYj?g;S+jPLZ2MC8 zEpA)iUwZXc@|w-v(2Mr_Po{d<9q;Y+%6pbo7@Xb3k?m22G3?fY_3W4Vb!TZxJxyW#iOp z^Jx3d%gD&h%3z>psAHhT#vIDREKE!$F_07IH8e3aFf=!`G&VN1h!W>Df^kiaEuu&^ zuW>%Ii-6gTxv`hQps|ywv5{flH`fH4sGK&FZJD+Uo@ZwH{aw0pZ*tSun_+&BMB=y^ z-c2e|JryhF@lboSqNJ$VMAPivsn=Wtr>-(y5UJYq_2(w@J=?sZzH4Uv+~XE=KG0oV z%k6FBuhuEy8?;t$$hlZO_hNdxV@r%s!{Sv3y`=Sau5!A_d*%0qkdsYQ+P9rwz|X|Y z$iRr~JYaw^1Kp*x$!6m!!+N$2U59F>+Ehlq%vy6f=7g$ll>JAT@7R&GCYog$eH$nhLh>b-VWDfl~L?*gnZUEWO_nVto$@tppcqEGenE`Oq>; z4-w&0fssAYpz$|2zEk#1MRUFZzag&yHzdBnCLl$q1u#O*5D{u&Y-(&4g{c8wjI9pa zu+Hy-b{^ZzGkX*F$r^6imsY&X#BA}^xvfw1e#jhB*v@8j>~OT3Ko)0a!8^|-sngn? zJuh->vnjvpod0{y|A2!#CTlxJOT?K5E!SVTU{!Eb&au{-Pv<$}RhXETZ_@i~a>{Q0 zqUE0b5|y6wihq^uGu~!qEyNfuCde$>GWV-Kt{Bt!8Ol`uIwkVrY6hQMG0Vc--|c@> z_11Di$61H3Yb+f~Hfi3Uxw>}!`N=XhR-HG~JPhu~3%XW))cNBg+UGy3J|?IC()^$P zzJ;ylddv2%TfF-1tBtIV-#1IRPC2=Ef||6-p*3ssE@!Cj<9MC20gXI3Dk|qo%RL%nc;dRUo literal 0 HcmV?d00001 diff --git a/testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/picketlink.xml b/testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/picketlink.xml new file mode 100755 index 0000000000..beed463689 --- /dev/null +++ b/testsuite/integration/src/test/resources/saml/signed-get/WEB-INF/picketlink.xml @@ -0,0 +1,36 @@ + + + ${idp-sig.url::http://localhost:8081/auth/realms/demo/protocol/saml} + + ${employee-sig.url::http://localhost:8081/employee-sig/} + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testsuite/integration/src/test/resources/saml/simple-get/WEB-INF/picketlink.xml b/testsuite/integration/src/test/resources/saml/simple-get/WEB-INF/picketlink.xml new file mode 100755 index 0000000000..2fb11caca1 --- /dev/null +++ b/testsuite/integration/src/test/resources/saml/simple-get/WEB-INF/picketlink.xml @@ -0,0 +1,20 @@ + + + ${idp.url::http://localhost:8081/auth/realms/demo/protocol/saml} + ${employee.url::http://localhost:8081/employee/} + + + + + + + + + + \ No newline at end of file diff --git a/testsuite/integration/src/test/resources/saml/simple-post/WEB-INF/picketlink.xml b/testsuite/integration/src/test/resources/saml/simple-post/WEB-INF/picketlink.xml new file mode 100755 index 0000000000..4e20d7e401 --- /dev/null +++ b/testsuite/integration/src/test/resources/saml/simple-post/WEB-INF/picketlink.xml @@ -0,0 +1,20 @@ + + + ${idp.url::http://localhost:8081/auth/realms/demo/protocol/saml} + ${sales-post.url::http://localhost:8081/sales-post/} + + localhost,jboss.com,jboss.org,amazonaws.com + + + + + + + + + \ No newline at end of file