commit | author | age
|
5686c9
|
1 |
import org.junit.Test |
JK |
2 |
|
|
3 |
import org.openqa.selenium.WebDriver |
|
4 |
import org.openqa.selenium.By |
|
5 |
|
|
6 |
import org.junit.runner.RunWith |
|
7 |
import org.junit.runners.Parameterized |
|
8 |
import org.junit.runners.Parameterized.Parameter |
|
9 |
import org.junit.runners.Parameterized.Parameters |
|
10 |
|
|
11 |
import Config |
|
12 |
import Common |
|
13 |
|
|
14 |
@RunWith(Parameterized.class) |
|
15 |
class StandardTests { |
9da16f
|
16 |
@Parameters(name = "{0}") |
5686c9
|
17 |
public static Iterable<Object[]> data() { |
JK |
18 |
return [ |
aec94b
|
19 |
// name, cas, cafile, method, login page expected text, main page expected text |
5686c9
|
20 |
|
JK |
21 |
// HTTP should succeed |
9da16f
|
22 |
[ "HTTP", "http://127.0.0.1:8081/cas.php", null, null, "Authenticated as user123", "Authenticated as user123" ] as Object[], |
JK |
23 |
[ "HTTP GET", "http://127.0.0.1:8081/cas.php", null, "GET", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
24 |
[ "HTTP POST", "http://127.0.0.1:8081/cas.php", null, "POST", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
5686c9
|
25 |
|
JK |
26 |
// HTTPS should succeed |
aec94b
|
27 |
[ "HTTPS", "https://127.0.0.1:8444/cas.php", "/tmp/ca.crt", null, "Authenticated as user123", "Authenticated as user123" ] as Object[], |
JK |
28 |
[ "HTTPS GET", "https://127.0.0.1:8444/cas.php", "/tmp/ca.crt", "GET", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
29 |
[ "HTTPS POST", "https://127.0.0.1:8444/cas.php", "/tmp/ca.crt", "POST", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
30 |
|
|
31 |
// system CAfile does not contain CA certificate - should fail |
9da16f
|
32 |
[ "HTTPS SysCA", "https://127.0.0.1:8444/cas.php", null, null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
JK |
33 |
[ "HTTPS SysCA GET", "https://127.0.0.1:8444/cas.php", null, "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
34 |
[ "HTTPS SysCA POST", "https://127.0.0.1:8444/cas.php", null, "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
aec94b
|
35 |
// correct.crt is a leaf certificate - should fail |
JK |
36 |
[ "HTTPS LeafCA", "https://127.0.0.1:8444/cas.php", "/tmp/correct.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
37 |
[ "HTTPS LeafCA GET", "https://127.0.0.1:8444/cas.php", "/tmp/correct.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
38 |
[ "HTTPS LeafCA POST", "https://127.0.0.1:8444/cas.php", "/tmp/correct.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
5686c9
|
39 |
// wrongcn.crt does not contain correct.crt - should fail |
9da16f
|
40 |
[ "HTTPS WrongCA", "https://127.0.0.1:8444/cas.php", "/tmp/wrongcn.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
JK |
41 |
[ "HTTPS WrongCA GET", "https://127.0.0.1:8444/cas.php", "/tmp/wrongcn.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
42 |
[ "HTTPS WrongCA POST", "https://127.0.0.1:8444/cas.php", "/tmp/wrongcn.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
5686c9
|
43 |
|
JK |
44 |
// system CAfile does not contain this self-signed certificate - should fail |
9da16f
|
45 |
[ "HTTPS2 SysCA", "https://127.0.0.1:8445/cas.php", null, null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
JK |
46 |
[ "HTTPS2 SysCA GET", "https://127.0.0.1:8445/cas.php", null, "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
47 |
[ "HTTPS2 SysCA POST", "https://127.0.0.1:8445/cas.php", null, "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
5686c9
|
48 |
// correct.crt does not contain wrongcn.crt - should fail |
9da16f
|
49 |
[ "HTTPS2 WrongCA", "https://127.0.0.1:8445/cas.php", "/tmp/correct.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
JK |
50 |
[ "HTTPS2 WrongCA GET", "https://127.0.0.1:8445/cas.php", "/tmp/correct.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
51 |
[ "HTTPS2 WrongCA POST", "https://127.0.0.1:8445/cas.php", "/tmp/correct.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
aec94b
|
52 |
// wrongcn.crt is a leaf certificate - should fail |
JK |
53 |
[ "HTTPS2 WrongCN", "https://127.0.0.1:8445/cas.php", "/tmp/wrongcn.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
54 |
[ "HTTPS2 WrongCN GET", "https://127.0.0.1:8445/cas.php", "/tmp/wrongcn.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
55 |
[ "HTTPS2 WrongCN POST", "https://127.0.0.1:8445/cas.php", "/tmp/wrongcn.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
5686c9
|
56 |
// wrongcn.crt is issued to 127.0.0.2, not 127.0.0.1 - should fail |
aec94b
|
57 |
[ "HTTPS2 CA+WrongCN", "https://127.0.0.1:8445/cas.php", "/tmp/ca.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
JK |
58 |
[ "HTTPS2 CA+WrongCN GET", "https://127.0.0.1:8445/cas.php", "/tmp/ca.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
59 |
[ "HTTPS2 CA+WrongCN POST", "https://127.0.0.1:8445/cas.php", "/tmp/ca.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
5686c9
|
60 |
] |
JK |
61 |
} |
|
62 |
|
|
63 |
@Parameter(0) |
9da16f
|
64 |
public String name |
5686c9
|
65 |
@Parameter(1) |
9da16f
|
66 |
public String cas |
5686c9
|
67 |
@Parameter(2) |
9da16f
|
68 |
public String cafile |
5686c9
|
69 |
@Parameter(3) |
9da16f
|
70 |
public String method |
5686c9
|
71 |
@Parameter(4) |
9da16f
|
72 |
public String expectLogin |
JK |
73 |
@Parameter(5) |
5686c9
|
74 |
public String expectMain |
JK |
75 |
|
|
76 |
@Test |
|
77 |
public void testSinglePage() { |
|
78 |
WebDriver driver = Common.set(cas, cafile, method) |
|
79 |
|
|
80 |
def url = Config.baseUrl + "/basic/" |
|
81 |
Common.loginSingle(url, driver) |
|
82 |
|
|
83 |
if(method.equals("GET")) { |
|
84 |
assert driver.getCurrentUrl().contains("ticket=") |
|
85 |
} else { |
|
86 |
assert !driver.getCurrentUrl().contains("ticket=") |
|
87 |
} |
|
88 |
|
|
89 |
// Post-login |
|
90 |
assert driver.getPageSource().contains(expectLogin) |
|
91 |
} |
|
92 |
|
|
93 |
@Test |
|
94 |
public void testMultiPage() { |
|
95 |
WebDriver driver = Common.set(cas, cafile, method) |
|
96 |
|
|
97 |
def url = Config.baseUrl + "/login-page/" |
|
98 |
Common.loginMulti(url, driver) |
|
99 |
|
|
100 |
// Post-login |
|
101 |
assert driver.getPageSource().contains(expectLogin) |
|
102 |
|
|
103 |
// Main page (again) |
|
104 |
driver.get(url) |
|
105 |
assert driver.getPageSource().contains(expectMain) |
|
106 |
} |
|
107 |
} |