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 { |
|
16 |
@Parameters |
|
17 |
public static Iterable<Object[]> data() { |
|
18 |
return [ |
|
19 |
// cas, cafile, method, login page expected text, main page expected text |
|
20 |
|
|
21 |
// HTTP should succeed |
|
22 |
[ "http://127.0.0.1:8081/cas.php", null, null, "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
23 |
[ "http://127.0.0.1:8081/cas.php", null, "GET", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
24 |
[ "http://127.0.0.1:8081/cas.php", null, "POST", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
25 |
|
|
26 |
// HTTPS should succeed |
|
27 |
[ "https://127.0.0.1:8444/cas.php", "/tmp/correct.crt", null, "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
28 |
[ "https://127.0.0.1:8444/cas.php", "/tmp/correct.crt", "GET", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
29 |
[ "https://127.0.0.1:8444/cas.php", "/tmp/correct.crt", "POST", "Authenticated as user123", "Authenticated as user123" ] as Object[], |
|
30 |
|
|
31 |
// system CAfile does not contain this self-signed certificate - should fail |
|
32 |
[ "https://127.0.0.1:8444/cas.php", null, null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
33 |
[ "https://127.0.0.1:8444/cas.php", null, "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
34 |
[ "https://127.0.0.1:8444/cas.php", null, "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
35 |
// wrongcn.crt does not contain correct.crt - should fail |
|
36 |
[ "https://127.0.0.1:8444/cas.php", "/tmp/wrongcn.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
37 |
[ "https://127.0.0.1:8444/cas.php", "/tmp/wrongcn.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
38 |
[ "https://127.0.0.1:8444/cas.php", "/tmp/wrongcn.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
39 |
|
|
40 |
// system CAfile does not contain this self-signed certificate - should fail |
|
41 |
[ "https://127.0.0.1:8445/cas.php", null, null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
42 |
[ "https://127.0.0.1:8445/cas.php", null, "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
43 |
[ "https://127.0.0.1:8445/cas.php", null, "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
44 |
// correct.crt does not contain wrongcn.crt - should fail |
|
45 |
[ "https://127.0.0.1:8445/cas.php", "/tmp/correct.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
46 |
[ "https://127.0.0.1:8445/cas.php", "/tmp/correct.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
47 |
[ "https://127.0.0.1:8445/cas.php", "/tmp/correct.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
48 |
// wrongcn.crt is issued to 127.0.0.2, not 127.0.0.1 - should fail |
|
49 |
[ "https://127.0.0.1:8445/cas.php", "/tmp/wrongcn.crt", null, "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
50 |
[ "https://127.0.0.1:8445/cas.php", "/tmp/wrongcn.crt", "GET", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
51 |
[ "https://127.0.0.1:8445/cas.php", "/tmp/wrongcn.crt", "POST", "CAS server is unavailable", "Not authenticated." ] as Object[], |
|
52 |
] |
|
53 |
} |
|
54 |
|
|
55 |
@Parameter(0) |
|
56 |
public String cas |
|
57 |
@Parameter(1) |
|
58 |
public String cafile |
|
59 |
@Parameter(2) |
|
60 |
public String method |
|
61 |
@Parameter(3) |
|
62 |
public String expectLogin |
|
63 |
@Parameter(4) |
|
64 |
public String expectMain |
|
65 |
|
|
66 |
@Test |
|
67 |
public void testSinglePage() { |
|
68 |
WebDriver driver = Common.set(cas, cafile, method) |
|
69 |
|
|
70 |
def url = Config.baseUrl + "/basic/" |
|
71 |
Common.loginSingle(url, driver) |
|
72 |
|
|
73 |
if(method.equals("GET")) { |
|
74 |
assert driver.getCurrentUrl().contains("ticket=") |
|
75 |
} else { |
|
76 |
assert !driver.getCurrentUrl().contains("ticket=") |
|
77 |
} |
|
78 |
|
|
79 |
// Post-login |
|
80 |
assert driver.getPageSource().contains(expectLogin) |
|
81 |
} |
|
82 |
|
|
83 |
@Test |
|
84 |
public void testMultiPage() { |
|
85 |
WebDriver driver = Common.set(cas, cafile, method) |
|
86 |
|
|
87 |
def url = Config.baseUrl + "/login-page/" |
|
88 |
Common.loginMulti(url, driver) |
|
89 |
|
|
90 |
// Post-login |
|
91 |
assert driver.getPageSource().contains(expectLogin) |
|
92 |
|
|
93 |
// Main page (again) |
|
94 |
driver.get(url) |
|
95 |
assert driver.getPageSource().contains(expectMain) |
|
96 |
} |
|
97 |
} |