35
35
import org .junit .Test ;
36
36
import org .junit .runners .model .Statement ;
37
37
import org .jvnet .hudson .test .RestartableJenkinsRule ;
38
- import org .jvnet .hudson .test .RestartableJenkinsRule .Step ;
39
38
40
39
import static org .junit .Assert .assertFalse ;
41
40
import static org .junit .Assert .assertNotNull ;
@@ -70,10 +69,12 @@ private boolean IsWindowsOS() {
70
69
*/
71
70
@ Test
72
71
public void testNegotiateHasConfigPage () {
73
- rule .then (r -> {
74
- HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
75
- HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
76
- assertNotNull ("Negotiate configuration page missing." , enabled );
72
+ rule .addStep (new Statement () {
73
+ @ Override public void evaluate () throws Throwable {
74
+ HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
75
+ HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
76
+ assertNotNull ("Negotiate configuration page missing." , enabled );
77
+ }
77
78
});
78
79
79
80
}
@@ -83,11 +84,13 @@ public void testNegotiateHasConfigPage() {
83
84
*/
84
85
@ Test
85
86
public void testEnableNegotiate () {
86
- rule .then (r -> {
87
- HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
88
- HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
89
- enabled .fireEvent ("click" );
90
- assertNotNull ("Optional block wasn't expanded." , currentPage .getElementByName ("_.redirectEnabled" ));
87
+ rule .addStep (new Statement () {
88
+ @ Override public void evaluate () throws Throwable {
89
+ HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
90
+ HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
91
+ enabled .fireEvent ("click" );
92
+ assertNotNull ("Optional block wasn't expanded." , currentPage .getElementByName ("_.redirectEnabled" ));
93
+ }
91
94
});
92
95
}
93
96
@@ -97,30 +100,32 @@ public void testEnableNegotiate() {
97
100
*/
98
101
@ Test
99
102
public void testIfConfigCanBeUpdated () throws Exception {
100
- rule .then (r -> {
101
- assertFalse ("Plugin already enabled" , NegotiateSSO .getInstance ().getEnabled ());
103
+ rule .addStep (new Statement () {
104
+ @ Override public void evaluate () throws Throwable {
105
+ assertFalse ("Plugin already enabled" , NegotiateSSO .getInstance ().getEnabled ());
106
+
107
+ HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
108
+ HtmlForm form = currentPage .getFormByName ("config" );
109
+ assertNotNull (form );
102
110
103
- HtmlPage currentPage = rule . j . createWebClient (). goTo ( "configureSecurity" );
104
- HtmlForm form = currentPage . getFormByName ( "config" );
105
- assertNotNull ( form );
111
+ form . getInputByName ( "_.enabled" ). click ( );
112
+ form . getSelectByName ( "_.principalFormat" ). setSelectedAttribute ( "both" , true );
113
+ form . getSelectByName ( "_.roleFormat" ). setSelectedAttribute ( "sid" , true );
106
114
107
- form .getInputByName ("_.enabled" ).click ();
108
- form .getSelectByName ("_.principalFormat" ).setSelectedAttribute ("both" , true );
109
- form .getSelectByName ("_.roleFormat" ).setSelectedAttribute ("sid" , true );
115
+ try {
116
+ rule .j .submit (form );
117
+ // CS IGNORE EmptyBlock FOR NEXT 3 LINES. REASON: Mocks Tests.
118
+ } catch (FailingHttpStatusCodeException e ) {
119
+ // Expected since filter cannot be added to Jenkins rule.
120
+ }
110
121
111
- try {
112
- rule .j .submit (form );
113
- // CS IGNORE EmptyBlock FOR NEXT 3 LINES. REASON: Mocks Tests.
114
- } catch (FailingHttpStatusCodeException e ) {
115
- // Expected since filter cannot be added to Jenkins rule.
116
- }
117
-
118
- boolean wasEnabled = NegotiateSSO .getInstance ().getEnabled ();
119
- if (IsWindowsOS ()) {
120
- assertTrue ("Plugin wasn't enabled after saving the new config" , wasEnabled );
121
- }
122
- else {
123
- assertFalse ("Plugin was enabled on a non-Windows OS" , wasEnabled );
122
+ boolean wasEnabled = NegotiateSSO .getInstance ().getEnabled ();
123
+ if (IsWindowsOS ()) {
124
+ assertTrue ("Plugin wasn't enabled after saving the new config" , wasEnabled );
125
+ }
126
+ else {
127
+ assertFalse ("Plugin was enabled on a non-Windows OS" , wasEnabled );
128
+ }
124
129
}
125
130
});
126
131
}
0 commit comments