11/*******************************************************************************
22 * Cloud Foundry
33 * Copyright (c) [2009-2016] Pivotal Software, Inc. All Rights Reserved.
4- *
4+ * <p/>
55 * This product is licensed to you under the Apache License, Version 2.0 (the "License").
66 * You may not use this product except in compliance with the License.
7- *
7+ * <p/>
88 * This product includes a number of subcomponents with
99 * separate copyright notices and license terms. Your use of these
1010 * subcomponents is subject to the terms and conditions of the
@@ -203,7 +203,7 @@ void samlSPMetadata() {
203203 ResponseEntity <String > response = request .getForEntity (
204204 baseUrl + "/saml/metadata" , String .class );
205205 assertThat (response .getStatusCode ()).isEqualTo (HttpStatus .OK );
206- String metadataXml = ( String ) response .getBody ();
206+ String metadataXml = response .getBody ();
207207
208208 // The SAML SP metadata should match the following UAA configs:
209209 // login.entityID
@@ -264,7 +264,7 @@ void simpleSamlLoginWithAddShadowUserOnLoginFalse() throws Exception {
264264 // create a UAA user with the email address as the username.
265265 deleteUser (SAML_ORIGIN , testAccounts .getEmail ());
266266
267- IdentityProvider provider = IntegrationTestUtils .createIdentityProvider (SAML_ORIGIN , false , baseUrl , serverRunning );
267+ IdentityProvider <?> provider = IntegrationTestUtils .createIdentityProvider (SAML_ORIGIN , false , baseUrl , serverRunning );
268268 String clientId = "app-addnew-false" + new RandomValueStringGenerator ().generate ();
269269 String redirectUri = "http://nosuchhostname:0/nosuchendpoint" ;
270270 createClientAndSpecifyProvider (clientId , provider , redirectUri );
@@ -278,7 +278,7 @@ void simpleSamlLoginWithAddShadowUserOnLoginFalse() throws Exception {
278278 }
279279
280280 @ Test
281- @ Disabled ("SAML test fails" )
281+ @ Disabled ("SAML test fails: Requires zones " )
282282 void incorrectResponseFromSamlIDP_showErrorFromSaml () {
283283 String zoneId = "testzone3" ;
284284 String zoneUrl = baseUrl .replace ("localhost" , zoneId + ".localhost" );
@@ -311,7 +311,7 @@ void incorrectResponseFromSamlIDP_showErrorFromSaml() {
311311 "secr3T" );
312312
313313 SamlIdentityProviderDefinition samlIdentityProviderDefinition = createSimplePHPSamlIDP (SAML_ORIGIN , "testzone3" );
314- IdentityProvider provider = new IdentityProvider ();
314+ IdentityProvider < SamlIdentityProviderDefinition > provider = new IdentityProvider <> ();
315315 provider .setIdentityZoneId (zoneId );
316316 provider .setType (OriginKeys .SAML );
317317 provider .setActive (true );
@@ -343,10 +343,11 @@ void simpleSamlPhpLogin() throws Exception {
343343 }
344344
345345 @ Test
346- @ Disabled ("SAML test fails" )
346+ @ Disabled ("SAML test fails: requires LogoutRequest to be sent to the IDP " )
347347 void simpleSamlPhpLoginDisplaysLastLogin () throws Exception {
348+ createIdentityProvider (SAML_ORIGIN );
349+
348350 Long beforeTest = System .currentTimeMillis ();
349- IdentityProvider <SamlIdentityProviderDefinition > provider = createIdentityProvider (SAML_ORIGIN );
350351 LoginPage .go (webDriver , baseUrl )
351352 .clickSamlLink_goesToSamlLoginPage (SAML_ORIGIN )
352353 .login_goesToHomePage (testAccounts .getUserName (), testAccounts .getPassword ())
@@ -362,9 +363,9 @@ void simpleSamlPhpLoginDisplaysLastLogin() throws Exception {
362363 }
363364
364365 @ Test
365- @ Disabled ("SAML test fails" )
366+ @ Disabled ("SAML test fails: Requires logout " )
366367 void singleLogout () throws Exception {
367- IdentityProvider < SamlIdentityProviderDefinition > provider = createIdentityProvider (SAML_ORIGIN );
368+ createIdentityProvider (SAML_ORIGIN );
368369
369370 LoginPage .go (webDriver , baseUrl )
370371 .clickSamlLink_goesToSamlLoginPage (SAML_ORIGIN )
@@ -374,7 +375,7 @@ void singleLogout() throws Exception {
374375 }
375376
376377 @ Test
377- @ Disabled ("SAML test fails" )
378+ @ Disabled ("SAML test fails: Requires zones and logout " )
378379 void singleLogoutWithNoLogoutUrlOnIDPWithLogoutRedirect () {
379380 String zoneId = "testzone2" ;
380381 String zoneUrl = baseUrl .replace ("localhost" , zoneId + ".localhost" );
@@ -410,7 +411,7 @@ void singleLogoutWithNoLogoutUrlOnIDPWithLogoutRedirect() {
410411 email ,
411412 "secr3T" );
412413 SamlIdentityProviderDefinition providerDefinition = createIDPWithNoSLOSConfigured ();
413- IdentityProvider <SamlIdentityProviderDefinition > provider = new IdentityProvider ();
414+ IdentityProvider <SamlIdentityProviderDefinition > provider = new IdentityProvider <> ();
414415 provider .setIdentityZoneId (zoneId );
415416 provider .setType (OriginKeys .SAML );
416417 provider .setActive (true );
@@ -435,10 +436,10 @@ void singleLogoutWithNoLogoutUrlOnIDPWithLogoutRedirect() {
435436 }
436437
437438 @ Test
438- @ Disabled ("SAML test fails" )
439+ @ Disabled ("SAML test fails: Requires logout " )
439440 void singleLogoutWithNoLogoutUrlOnIDP () throws Exception {
440441 SamlIdentityProviderDefinition providerDefinition = createIDPWithNoSLOSConfigured ();
441- IdentityProvider <SamlIdentityProviderDefinition > provider = new IdentityProvider ();
442+ IdentityProvider <SamlIdentityProviderDefinition > provider = new IdentityProvider <> ();
442443 provider .setIdentityZoneId (OriginKeys .UAA );
443444 provider .setType (OriginKeys .SAML );
444445 provider .setActive (true );
@@ -447,8 +448,7 @@ void singleLogoutWithNoLogoutUrlOnIDP() throws Exception {
447448 provider .setName ("simplesamlphp for uaa" );
448449
449450 String zoneAdminToken = getZoneAdminToken (baseUrl , serverRunning );
450-
451- provider = IntegrationTestUtils .createOrUpdateProvider (zoneAdminToken , baseUrl , provider );
451+ IntegrationTestUtils .createOrUpdateProvider (zoneAdminToken , baseUrl , provider );
452452
453453 LoginPage .go (webDriver , baseUrl )
454454 .clickSamlLink_goesToSamlLoginPage ("simplesamlphp" )
@@ -474,31 +474,14 @@ void faviconShouldNotSave() throws Exception {
474474 .login_goesToHomePage (MARISSA4_USERNAME , MARISSA4_PASSWORD );
475475 }
476476
477-
478- private void testSimpleSamlLogin (String firstUrl , String lookfor ) throws Exception {
479- testSimpleSamlLogin (firstUrl , lookfor , testAccounts .getUserName (), testAccounts .getPassword ());
480- }
481-
482- private void testSimpleSamlLogin (String firstUrl , String lookfor , String username , String password ) throws Exception {
483- IdentityProvider <SamlIdentityProviderDefinition > provider = createIdentityProvider (SAML_ORIGIN );
484-
485- webDriver .get (baseUrl + firstUrl );
486- assertThat (webDriver .getTitle ()).isEqualTo ("Cloud Foundry" );
487- webDriver .findElement (By .xpath ("//a[text()='" + provider .getConfig ().getLinkText () + "']" )).click ();
488- //takeScreenShot();
489- assertThat (webDriver .getCurrentUrl ()).contains ("loginuserpass" );
490- sendCredentials (username , password );
491- assertThat (webDriver .findElement (By .cssSelector ("h1" )).getText ()).contains (lookfor );
492- }
493-
494477 protected IdentityProvider <SamlIdentityProviderDefinition > createIdentityProvider (String originKey ) throws Exception {
495478 return IntegrationTestUtils .createIdentityProvider (originKey , true , baseUrl , serverRunning );
496479 }
497480
498481 protected UaaClientDetails createClientAndSpecifyProvider (String clientId , IdentityProvider provider ,
499482 String redirectUri ) {
500483
501- RestTemplate identityClient = IntegrationTestUtils .getClientCredentialsTemplate (
484+ IntegrationTestUtils .getClientCredentialsTemplate (
502485 IntegrationTestUtils .getClientCredentialsResource (baseUrl , new String [0 ], "identity" , "identitysecret" )
503486 );
504487 RestTemplate adminClient = IntegrationTestUtils .getClientCredentialsTemplate (
@@ -529,7 +512,6 @@ protected UaaClientDetails createClientAndSpecifyProvider(String clientId, Ident
529512 }
530513
531514 protected void deleteUser (String origin , String username ) {
532-
533515 String zoneAdminToken = IntegrationTestUtils .getClientCredentialsToken (serverRunning ,
534516 "admin" , "adminsecret" );
535517
@@ -542,8 +524,8 @@ protected void deleteUser(String origin, String username) {
542524 }
543525
544526 @ Test
545- @ Disabled ("SAML test fails" )
546- void saml_invitation_automatic_redirect_in_zone2 () throws Exception {
527+ @ Disabled ("SAML test fails: Requires zones " )
528+ void saml_invitation_automatic_redirect_in_zone2 () {
547529 perform_SamlInvitation_Automatic_Redirect_In_Zone2 (MARISSA2_USERNAME , MARISSA2_PASSWORD , true );
548530 perform_SamlInvitation_Automatic_Redirect_In_Zone2 (MARISSA2_USERNAME , MARISSA2_PASSWORD , true );
549531 perform_SamlInvitation_Automatic_Redirect_In_Zone2 (MARISSA2_USERNAME , MARISSA2_PASSWORD , true );
@@ -643,7 +625,7 @@ public void perform_SamlInvitation_Automatic_Redirect_In_Zone2(String username,
643625 }
644626
645627 @ Test
646- @ Disabled ("SAML test fails" )
628+ @ Disabled ("SAML test fails: Requires zones " )
647629 void relay_state_redirect_from_idp () {
648630 //ensure we are able to resolve DNS for hostname testzone1.localhost
649631 String zoneId = "testzone1" ;
@@ -706,7 +688,7 @@ void relay_state_redirect_from_idp() {
706688 }
707689
708690 @ Test
709- @ Disabled ("SAML test fails" )
691+ @ Disabled ("SAML test fails: Requires zones " )
710692 void samlLoginClientIDPAuthorizationAutomaticRedirectInZone1 () {
711693 //ensure we are able to resolve DNS for hostname testzone1.localhost
712694 String zoneId = "testzone1" ;
@@ -758,7 +740,7 @@ void samlLoginClientIDPAuthorizationAutomaticRedirectInZone1() {
758740 clientDetails .setClientSecret ("secret" );
759741 clientDetails .addAdditionalInformation (ClientConstants .ALLOWED_PROVIDERS , idps );
760742 clientDetails .setAutoApproveScopes (Collections .singleton ("true" ));
761- clientDetails = IntegrationTestUtils .createClientAsZoneAdmin (zoneAdminToken , baseUrl , zoneId , clientDetails );
743+ IntegrationTestUtils .createClientAsZoneAdmin (zoneAdminToken , baseUrl , zoneId , clientDetails );
762744
763745 webDriver .get (zoneUrl + "/logout.do" );
764746
@@ -774,7 +756,7 @@ void samlLoginClientIDPAuthorizationAutomaticRedirectInZone1() {
774756 }
775757
776758 @ Test
777- @ Disabled ("SAML test fails" )
759+ @ Disabled ("SAML test fails: Requires zones and logout " )
778760 void samlLoginMapGroupsInZone1 () {
779761 //ensure we are able to resolve DNS for hostname testzone1.localhost
780762 String zoneId = "testzone1" ;
@@ -835,7 +817,6 @@ void samlLoginMapGroupsInZone1() {
835817 clientDetails = IntegrationTestUtils .createClientAsZoneAdmin (zoneAdminToken , baseUrl , zoneId , clientDetails );
836818 String adminTokenInZone = IntegrationTestUtils .getClientCredentialsToken (zoneUrl , clientDetails .getClientId (), "secret" );
837819
838-
839820 ScimGroup uaaSamlUserGroup = new ScimGroup (null , "uaa.saml.user" , zoneId );
840821 uaaSamlUserGroup = IntegrationTestUtils .createOrUpdateGroup (adminTokenInZone , null , zoneUrl , uaaSamlUserGroup );
841822
@@ -878,7 +859,7 @@ void samlLoginMapGroupsInZone1() {
878859 }
879860
880861 @ Test
881- @ Disabled ("SAML test fails" )
862+ @ Disabled ("SAML test fails: Requires zones and logout " )
882863 void samlLoginCustomUserAttributesAndRolesInIDToken () throws Exception {
883864
884865 final String COST_CENTER = "costCenter" ;
@@ -1029,9 +1010,8 @@ void samlLoginCustomUserAttributesAndRolesInIDToken() throws Exception {
10291010 assertThat (userInfoRoles ).containsExactlyInAnyOrder (expectedRoles );
10301011 }
10311012
1032- // TODO: work on this next
10331013 @ Test
1034- @ Disabled ("SAML test fails" )
1014+ @ Disabled ("SAML test fails: Requires zones and logout " )
10351015 void samlLoginEmailInIDTokenWhenUserIDIsNotEmail () {
10361016
10371017 //ensure we are able to resolve DNS for hostname testzone1.localhost
@@ -1069,8 +1049,7 @@ void samlLoginEmailInIDTokenWhenUserIDIsNotEmail() {
10691049 SamlIdentityProviderDefinition samlIdentityProviderDefinition = createTestZoneIDP (SAML_ORIGIN , zoneId );
10701050 samlIdentityProviderDefinition .addAttributeMapping (EMAIL_ATTRIBUTE_NAME , "emailAddress" );
10711051
1072- IdentityProvider <SamlIdentityProviderDefinition > provider = new IdentityProvider ();
1073- provider .setIdentityZoneId (zoneId );
1052+ IdentityProvider <SamlIdentityProviderDefinition > provider = new IdentityProvider <>();
10741053 provider .setType (OriginKeys .SAML );
10751054 provider .setActive (true );
10761055 provider .setConfig (samlIdentityProviderDefinition );
@@ -1091,7 +1070,7 @@ void samlLoginEmailInIDTokenWhenUserIDIsNotEmail() {
10911070 clientDetails = IntegrationTestUtils .createClientAsZoneAdmin (zoneAdminToken , baseUrl , zoneId , clientDetails );
10921071 clientDetails .setClientSecret ("secret" );
10931072
1094- String adminTokenInZone = IntegrationTestUtils .getClientCredentialsToken (zoneUrl , clientDetails .getClientId (), "secret" );
1073+ IntegrationTestUtils .getClientCredentialsToken (zoneUrl , clientDetails .getClientId (), "secret" );
10951074
10961075 webDriver .get (zoneUrl + "/logout.do" );
10971076
@@ -1140,7 +1119,7 @@ void samlLoginEmailInIDTokenWhenUserIDIsNotEmail() {
11401119
11411120
11421121 @ Test
1143- @ Disabled ("SAML test fails" )
1122+ @ Disabled ("SAML test fails: Requires zones and logout " )
11441123 void simpleSamlPhpLoginInTestZone1Works () {
11451124 String zoneId = "testzone1" ;
11461125
@@ -1159,7 +1138,6 @@ void simpleSamlPhpLoginInTestZone1Works() {
11591138 String groupId = IntegrationTestUtils .findGroupId (adminClient , baseUrl , "zones." + zoneId + ".admin" );
11601139 IntegrationTestUtils .addMemberToGroup (adminClient , baseUrl , user .getId (), groupId );
11611140
1162-
11631141 String zoneAdminToken =
11641142 IntegrationTestUtils .getAccessTokenByAuthCode (serverRunning ,
11651143 UaaTestAccounts .standard (serverRunning ),
@@ -1177,7 +1155,6 @@ void simpleSamlPhpLoginInTestZone1Works() {
11771155 provider .setOriginKey (samlIdentityProviderDefinition .getIdpEntityAlias ());
11781156 provider .setName ("simplesamlphp for testzone1" );
11791157
1180-
11811158 provider = IntegrationTestUtils .createOrUpdateProvider (zoneAdminToken , baseUrl , provider );
11821159
11831160 //we have to create two providers to avoid automatic redirect
@@ -1191,7 +1168,7 @@ void simpleSamlPhpLoginInTestZone1Works() {
11911168 provider1 .setConfig (samlIdentityProviderDefinition1 );
11921169 provider1 .setOriginKey (samlIdentityProviderDefinition1 .getIdpEntityAlias ());
11931170 provider1 .setName ("simplesamlphp 1 for testzone1" );
1194- provider1 = IntegrationTestUtils .createOrUpdateProvider (zoneAdminToken , baseUrl , provider1 );
1171+ IntegrationTestUtils .createOrUpdateProvider (zoneAdminToken , baseUrl , provider1 );
11951172
11961173 assertThat (provider .getId ()).isNotNull ();
11971174
@@ -1287,7 +1264,7 @@ void loginSamlOnlyProviderNoUsernamePassword() throws Exception {
12871264 }
12881265
12891266 @ Test
1290- @ Disabled ("SAML test fails" )
1267+ @ Disabled ("SAML test fails: Requires logout " )
12911268 void samlLoginClientIDPAuthorizationAutomaticRedirect () throws Exception {
12921269 IdentityProvider <SamlIdentityProviderDefinition > provider = createIdentityProvider (SAML_ORIGIN );
12931270 assertThat (provider .getConfig ().getIdpEntityAlias ()).isEqualTo (provider .getOriginKey ());
@@ -1334,7 +1311,7 @@ void loginClientIDPAuthorizationAlreadyLoggedIn() {
13341311 }
13351312
13361313 @ Test
1337- @ Disabled ("SAML test fails" )
1314+ @ Disabled ("SAML test fails: Requires logout " )
13381315 void springSamlEndpointsWithEmptyContext () throws IOException {
13391316 CallEmpptyPageAndCheckHttpStatusCode ("/saml/discovery" , 200 );
13401317 CallEmpptyPageAndCheckHttpStatusCode ("/saml/SingleLogout" , 400 );
@@ -1394,19 +1371,6 @@ private SamlIdentityProviderDefinition createIDPWithNoSLOSConfigured() {
13941371 return def ;
13951372 }
13961373
1397- private void logout () {
1398- webDriver .findElement (By .cssSelector (".dropdown-trigger" )).click ();
1399- webDriver .findElement (By .linkText ("Sign Out" )).click ();
1400- }
1401-
1402- private void login (IdentityProvider <SamlIdentityProviderDefinition > provider ) {
1403- webDriver .get (baseUrl + "/login" );
1404- assertThat (webDriver .getTitle ()).isEqualTo ("Cloud Foundry" );
1405- webDriver .findElement (By .xpath ("//a[text()='" + provider .getConfig ().getLinkText () + "']" )).click ();
1406- webDriver .findElement (By .xpath (SIMPLESAMLPHP_LOGIN_PROMPT_XPATH_EXPR ));
1407- sendCredentials (testAccounts .getUserName (), testAccounts .getPassword ());
1408- }
1409-
14101374 private void sendCredentials (String username , String password , By loginButtonSelector ) {
14111375 webDriver .findElement (By .name ("username" )).clear ();
14121376 webDriver .findElement (By .name ("username" )).sendKeys (username );
0 commit comments