Skip to content

Commit 61e52cb

Browse files
committed
test: update and cleanup flaky tests
1 parent 597bc09 commit 61e52cb

2 files changed

Lines changed: 280 additions & 249 deletions

File tree

plugin-core/examples/functional-test-app/src/integration-test/groovy/specs/DisableSpec.groovy

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,187 +16,186 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
package specs
2120

22-
import grails.testing.mixin.integration.Integration
2321
import pages.IndexPage
2422
import spock.lang.IgnoreIf
2523

24+
import grails.testing.mixin.integration.Integration
2625

2726
@Integration
2827
@IgnoreIf({ System.getProperty('TESTCONFIG') != 'misc' })
2928
class DisableSpec extends AbstractHyphenatedSecuritySpec {
3029

3130
void 'lock account'() {
3231
given:
33-
String username = 'admin'
32+
def username = 'admin'
3433

3534
when:
36-
login username
35+
login(username)
3736

3837
then:
39-
at IndexPage
38+
at(IndexPage)
4039

4140
when:
42-
go 'secure-annotated'
41+
go('secure-annotated')
4342

4443
then:
45-
pageSource.contains('you have ROLE_ADMIN')
44+
waitFor { pageSource.contains('you have ROLE_ADMIN') }
4645

4746
when:
4847
logout()
4948

5049
then:
51-
'false' == getUserProperty(username, 'accountLocked')
50+
getUserProperty(username, 'accountLocked') == 'false'
5251

5352
when:
54-
setUserProperty username, 'accountLocked', true
53+
setUserProperty(username, 'accountLocked', true)
5554

5655
then:
57-
'true' == getUserProperty(username, 'accountLocked')
56+
getUserProperty(username, 'accountLocked') == 'true'
5857

5958
when:
60-
login username
59+
login(username)
6160

6261
then:
63-
pageSource.contains('accountLocked')
62+
waitFor { pageSource.contains('accountLocked') }
6463

6564
// reset
6665
when:
67-
setUserProperty username, 'accountLocked', false
66+
setUserProperty(username, 'accountLocked', false)
6867

6968
then:
70-
'false' == getUserProperty(username, 'accountLocked')
69+
getUserProperty(username, 'accountLocked') == 'false'
7170
}
7271

7372
void 'disable account'() {
7473
given:
75-
String username = 'admin'
74+
def username = 'admin'
7675

7776
when:
78-
login username
77+
login(username)
7978

8079
then:
81-
at IndexPage
80+
at(IndexPage)
8281

8382
when:
84-
go 'secure-annotated'
83+
go('secure-annotated')
8584

8685
then:
87-
pageSource.contains('you have ROLE_ADMIN')
86+
waitFor { pageSource.contains('you have ROLE_ADMIN') }
8887

8988
when:
9089
logout()
9190

9291
then:
93-
'true' == getUserProperty(username, 'enabled')
92+
getUserProperty(username, 'enabled') == 'true'
9493

9594
when:
96-
setUserProperty username, 'enabled', false
95+
setUserProperty(username, 'enabled', false)
9796

9897
then:
99-
'false' == getUserProperty(username, 'enabled')
98+
getUserProperty(username, 'enabled') == 'false'
10099

101100
when:
102-
login username
101+
login(username)
103102

104103
then:
105-
pageSource.contains('accountDisabled')
104+
waitFor { pageSource.contains('accountDisabled') }
106105

107106
// reset
108107
when:
109-
setUserProperty username, 'enabled', true
108+
setUserProperty(username, 'enabled', true)
110109

111110
then:
112-
'true' == getUserProperty(username, 'enabled')
111+
getUserProperty(username, 'enabled') == 'true'
113112
}
114113

115114
void 'expire account'() {
116115
given:
117-
String username = 'admin'
116+
def username = 'admin'
118117

119118
when:
120-
login username
119+
login(username)
121120

122121
then:
123-
at IndexPage
122+
at(IndexPage)
124123

125124
when:
126-
go 'secure-annotated'
125+
go('secure-annotated')
127126

128127
then:
129-
pageSource.contains('you have ROLE_ADMIN')
128+
waitFor { pageSource.contains('you have ROLE_ADMIN') }
130129

131130
when:
132131
logout()
133132

134133
then:
135-
'false' == getUserProperty(username, 'accountExpired')
134+
getUserProperty(username, 'accountExpired') == 'false'
136135

137136
when:
138-
setUserProperty username, 'accountExpired', true
137+
setUserProperty(username, 'accountExpired', true)
139138

140139
then:
141-
'true' == getUserProperty(username, 'accountExpired')
140+
getUserProperty(username, 'accountExpired') == 'true'
142141

143142
when:
144-
login username
143+
login(username)
145144

146145
then:
147-
pageSource.contains('accountExpired')
146+
waitFor { pageSource.contains('accountExpired') }
148147

149148
// reset
150149
when:
151-
setUserProperty username, 'accountExpired', false
150+
setUserProperty(username, 'accountExpired', false)
152151

153152
then:
154-
'false' == getUserProperty(username, 'accountExpired')
153+
getUserProperty(username, 'accountExpired') == 'false'
155154
}
156155

157156
void 'expire password'() {
158157
given:
159-
String username = 'admin'
158+
def username = 'admin'
160159

161160
when:
162-
login username
161+
login(username)
163162

164163
then:
165-
at IndexPage
164+
at(IndexPage)
166165

167166
when:
168-
go 'secure-annotated'
167+
go('secure-annotated')
169168

170169
then:
171-
pageSource.contains('you have ROLE_ADMIN')
170+
waitFor { pageSource.contains('you have ROLE_ADMIN') }
172171

173172
when:
174173
logout()
175174

176175
then:
177-
'false' == getUserProperty(username, 'passwordExpired')
176+
getUserProperty(username, 'passwordExpired') == 'false'
178177

179178
when:
180-
setUserProperty username, 'passwordExpired', true
179+
setUserProperty(username, 'passwordExpired', true)
181180

182181
then:
183-
'true' == getUserProperty(username, 'passwordExpired')
182+
getUserProperty(username, 'passwordExpired') == 'true'
184183

185184
when:
186-
login username
185+
login(username)
187186

188187
then:
189-
pageSource.contains('passwordExpired')
188+
waitFor { pageSource.contains('passwordExpired') }
190189

191190
// reset
192191
when:
193-
setUserProperty username, 'passwordExpired', false
192+
setUserProperty(username, 'passwordExpired', false)
194193

195194
then:
196-
'false' == getUserProperty(username, 'passwordExpired')
195+
getUserProperty(username, 'passwordExpired') == 'false'
197196
}
198197

199198
private void setUserProperty(String user, String propertyName, value) {
200-
go "hack/set-user-property?user=$user&$propertyName=$value"
199+
go("hack/set-user-property?user=$user&$propertyName=$value")
201200
}
202201
}

0 commit comments

Comments
 (0)