Skip to content

Commit 2e2b22f

Browse files
michael-simonsrwinch
authored andcommitted
Migrate xml-insecure groovy->java
See #4939.
1 parent 6ba225b commit 2e2b22f

File tree

5 files changed

+122
-68
lines changed

5 files changed

+122
-68
lines changed

samples/xml/insecure/spring-security-samples-xml-insecure.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
apply plugin: 'io.spring.convention.spring-sample-war'
218

319
dependencies {
@@ -7,5 +23,5 @@ dependencies {
723
providedCompile 'javax.servlet:javax.servlet-api'
824
providedCompile 'javax.servlet.jsp:javax.servlet.jsp-api'
925

10-
integrationTestCompile gebDependencies
26+
integrationTestCompile seleniumDependencies
1127
}

samples/xml/insecure/src/integration-test/groovy/org/springframework/security/samples/HelloInsecureTests.groovy

Lines changed: 0 additions & 36 deletions
This file was deleted.

samples/xml/insecure/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy

Lines changed: 0 additions & 31 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.security.samples;
17+
18+
import org.junit.After;
19+
import org.junit.Before;
20+
import org.junit.Test;
21+
import org.openqa.selenium.WebDriver;
22+
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
23+
import org.springframework.security.samples.pages.HomePage;
24+
25+
/**
26+
* @author Michael Simons
27+
*/
28+
public class HelloInsecureTests {
29+
30+
private WebDriver driver;
31+
32+
private int port;
33+
34+
@Before
35+
public void setup() {
36+
this.port = Integer.parseInt(System.getProperty("app.httpPort"));
37+
this.driver = new HtmlUnitDriver();
38+
}
39+
40+
@After
41+
public void tearDown() {
42+
this.driver.quit();
43+
}
44+
45+
@Test
46+
public void theHomePageIsAccessible() {
47+
HomePage.to(this.driver, this.port)
48+
.assertAt()
49+
.andWeCanSeeTheMessage();
50+
}
51+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2002-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.security.samples.pages;
17+
18+
import org.openqa.selenium.WebDriver;
19+
import org.openqa.selenium.WebElement;
20+
import org.openqa.selenium.support.FindBy;
21+
import org.openqa.selenium.support.PageFactory;
22+
23+
import static org.assertj.core.api.Assertions.assertThat;
24+
25+
/**
26+
* @author Michael Simons
27+
*/
28+
public class HomePage {
29+
private final WebDriver webDriver;
30+
31+
public HomePage(WebDriver webDriver) {
32+
this.webDriver = webDriver;
33+
}
34+
35+
public static HomePage to(WebDriver driver, int port) {
36+
driver.get("http://localhost:" + port +"/");
37+
return PageFactory.initElements(driver, HomePage.class);
38+
}
39+
40+
public Content assertAt() {
41+
assertThat(this.webDriver.getTitle()).isEqualTo("Hello World");
42+
return PageFactory.initElements(this.webDriver, Content.class);
43+
}
44+
45+
public static class Content {
46+
@FindBy(css = "p")
47+
private WebElement message;
48+
49+
public Content andWeCanSeeTheMessage() {
50+
assertThat(message.getText()).isEqualTo("We would like to secure this page");
51+
return this;
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)