Skip to content

Commit 604c64e

Browse files
committed
test: cleanup
1 parent 667c925 commit 604c64e

File tree

8 files changed

+285
-289
lines changed

8 files changed

+285
-289
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,28 @@ abstract class AbstractSecuritySpec extends ContainerGebSpec {
6363
}
6464

6565
protected String getContent(String url) {
66-
go url
66+
go(url)
6767
$().text()
6868
}
6969

7070
protected String getSessionValue(String name) {
71-
getContent 'hack/getSessionValue?name=' + name
71+
getContent("hack/getSessionValue?name=$name")
7272
}
7373

7474
protected void login(String user, String pwd = 'password', boolean remember = false) {
75-
to LoginPage
76-
username = user
77-
password = pwd
75+
def loginPage = to(LoginPage)
76+
loginPage.username = user
77+
loginPage.password = pwd
7878
if (remember) {
79-
rememberMe.click()
79+
loginPage.rememberMe.click()
8080
}
81-
loginButton.click()
81+
loginPage.loginButton.click()
8282
}
8383

8484
protected void logout() {
85-
go SpringSecurityUtils.securityConfig.logout.filterProcessesUrl
85+
go(SpringSecurityUtils.securityConfig.logout.filterProcessesUrl)
8686
browser.clearCookies()
87-
browser.go("/")
88-
}
89-
90-
protected void assertContentContains(String expected) {
91-
assert $().text().contains(expected)
92-
}
93-
94-
protected void assertContentDoesNotContain(String unexpected) {
95-
assert !$().text().contains(unexpected)
87+
browser.go('/')
9688
}
9789

9890
protected MessageDigestPasswordEncoder createSha256Encoder() {

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -214,73 +214,73 @@ class AnnotationSecuritySpec extends AbstractSecuritySpec {
214214
go 'secureAnnotated'
215215

216216
then:
217-
assertContentContains 'you have ROLE_ADMIN'
217+
pageSource.contains('you have ROLE_ADMIN')
218218

219219
when:
220220
go 'secureAnnotated/index'
221221

222222
then:
223-
assertContentContains 'you have ROLE_ADMIN'
223+
pageSource.contains('you have ROLE_ADMIN')
224224

225225
when:
226226
go 'secureAnnotated/adminEither'
227227

228228
then:
229-
assertContentContains 'you have ROLE_ADMIN'
229+
pageSource.contains('you have ROLE_ADMIN')
230230

231231
when:
232232
go 'secureClassAnnotated'
233233

234234
then:
235-
assertContentContains 'you have ROLE_ADMIN'
235+
pageSource.contains('you have ROLE_ADMIN')
236236

237237
when:
238238
go 'secureClassAnnotated/index'
239239

240240
then:
241-
assertContentContains 'you have ROLE_ADMIN'
241+
pageSource.contains('you have ROLE_ADMIN')
242242

243243
when:
244244
go 'secureClassAnnotated/otherAction'
245245

246246
then:
247-
assertContentContains 'you have ROLE_ADMIN'
247+
pageSource.contains('you have ROLE_ADMIN')
248248

249249
when:
250250
go 'secureClassAnnotated/admin2'
251251

252252
then:
253-
assertContentContains "Sorry, you're not authorized to view this page."
253+
pageSource.contains('Sorry, you\'re not authorized to view this page.')
254254

255255
when:
256256
go 'secureAnnotated/expression'
257257

258258
then:
259-
assertContentContains 'expression: OK'
259+
pageSource.contains('expression: OK')
260260

261261
when:
262262
go 'secureAnnotated/indexMethod'
263263

264264
then:
265-
assertContentContains 'you have ROLE_ADMIN'
265+
pageSource.contains('you have ROLE_ADMIN')
266266

267267
when:
268268
go 'secureAnnotated/adminEitherMethod'
269269

270270
then:
271-
assertContentContains 'you have ROLE_ADMIN'
271+
pageSource.contains('you have ROLE_ADMIN')
272272

273273
when:
274274
go 'secureAnnotated/expressionMethod'
275275

276276
then:
277-
assertContentContains 'OK - method'
277+
pageSource.contains('OK - method')
278278

279279
when:
280280
go 'secureAnnotated/closureMethod'
281281

282282
then:
283-
assertContentContains 'OK - closureMethod'
283+
pageSource.contains('OK - closureMethod')
284284
}
285285

286286
void 'check allowed for admin2'() {
@@ -295,73 +295,73 @@ class AnnotationSecuritySpec extends AbstractSecuritySpec {
295295
go 'secureAnnotated'
296296

297297
then:
298-
assertContentContains 'you have ROLE_ADMIN'
298+
pageSource.contains('you have ROLE_ADMIN')
299299

300300
when:
301301
go 'secureAnnotated/index'
302302

303303
then:
304-
assertContentContains 'you have ROLE_ADMIN'
304+
pageSource.contains('you have ROLE_ADMIN')
305305

306306
when:
307307
go 'secureAnnotated/adminEither'
308308

309309
then:
310-
assertContentContains 'you have ROLE_ADMIN'
310+
pageSource.contains('you have ROLE_ADMIN')
311311

312312
when:
313313
go 'secureClassAnnotated'
314314

315315
then:
316-
assertContentContains 'index: you have ROLE_ADMIN'
316+
pageSource.contains('index: you have ROLE_ADMIN')
317317

318318
when:
319319
go 'secureClassAnnotated/index'
320320

321321
then:
322-
assertContentContains 'index: you have ROLE_ADMIN'
322+
pageSource.contains('index: you have ROLE_ADMIN')
323323

324324
when:
325325
go 'secureClassAnnotated/otherAction'
326326

327327
then:
328-
assertContentContains 'otherAction: you have ROLE_ADMIN'
328+
pageSource.contains('otherAction: you have ROLE_ADMIN')
329329

330330
when:
331331
go 'secureClassAnnotated/admin2'
332332

333333
then:
334-
assertContentContains 'admin2: you have ROLE_ADMIN2'
334+
pageSource.contains('admin2: you have ROLE_ADMIN2')
335335

336336
when:
337337
go 'secureAnnotated/expression'
338338

339339
then:
340-
assertContentContains "Sorry, you're not authorized to view this page."
340+
pageSource.contains('Sorry, you\'re not authorized to view this page.')
341341

342342
when:
343343
go 'secureAnnotated/indexMethod'
344344

345345
then:
346-
assertContentContains 'you have ROLE_ADMIN'
346+
pageSource.contains('you have ROLE_ADMIN')
347347

348348
when:
349349
go 'secureAnnotated/adminEitherMethod'
350350

351351
then:
352-
assertContentContains 'you have ROLE_ADMIN'
352+
pageSource.contains('you have ROLE_ADMIN')
353353

354354
when:
355355
go 'secureAnnotated/expressionMethod'
356356

357357
then:
358-
assertContentContains "Sorry, you're not authorized to view this page."
358+
pageSource.contains('Sorry, you\'re not authorized to view this page.')
359359

360360
when:
361361
go 'secureAnnotated/closureMethod'
362362

363363
then:
364-
assertContentContains "Sorry, you're not authorized to view this page."
364+
pageSource.contains('Sorry, you\'re not authorized to view this page.')
365365
}
366366

367367
void 'restful domains can be secured'() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class BasicAuthCacheUsersSecuritySpec extends AbstractSecuritySpec {
148148
login 'admin1', 'password1'
149149

150150
then:
151-
assertContentContains 'you have ROLE_ADMIN'
151+
pageSource.contains('you have ROLE_ADMIN')
152152

153153
and:
154154
userCache.getUserFromCache('admin1')

0 commit comments

Comments
 (0)