|
16 | 16 | * specific language governing permissions and limitations |
17 | 17 | * under the License. |
18 | 18 | */ |
19 | | - |
20 | 19 | package specs |
21 | 20 |
|
22 | | -import grails.testing.mixin.integration.Integration |
23 | 21 | import pages.IndexPage |
24 | 22 | import spock.lang.IgnoreIf |
25 | 23 |
|
| 24 | +import grails.testing.mixin.integration.Integration |
26 | 25 |
|
27 | 26 | @Integration |
28 | 27 | @IgnoreIf({ System.getProperty('TESTCONFIG') != 'misc' }) |
29 | 28 | class DisableSpec extends AbstractHyphenatedSecuritySpec { |
30 | 29 |
|
31 | 30 | void 'lock account'() { |
32 | 31 | given: |
33 | | - String username = 'admin' |
| 32 | + def username = 'admin' |
34 | 33 |
|
35 | 34 | when: |
36 | | - login username |
| 35 | + login(username) |
37 | 36 |
|
38 | 37 | then: |
39 | | - at IndexPage |
| 38 | + at(IndexPage) |
40 | 39 |
|
41 | 40 | when: |
42 | | - go 'secure-annotated' |
| 41 | + go('secure-annotated') |
43 | 42 |
|
44 | 43 | then: |
45 | | - pageSource.contains('you have ROLE_ADMIN') |
| 44 | + waitFor { pageSource.contains('you have ROLE_ADMIN') } |
46 | 45 |
|
47 | 46 | when: |
48 | 47 | logout() |
49 | 48 |
|
50 | 49 | then: |
51 | | - 'false' == getUserProperty(username, 'accountLocked') |
| 50 | + getUserProperty(username, 'accountLocked') == 'false' |
52 | 51 |
|
53 | 52 | when: |
54 | | - setUserProperty username, 'accountLocked', true |
| 53 | + setUserProperty(username, 'accountLocked', true) |
55 | 54 |
|
56 | 55 | then: |
57 | | - 'true' == getUserProperty(username, 'accountLocked') |
| 56 | + getUserProperty(username, 'accountLocked') == 'true' |
58 | 57 |
|
59 | 58 | when: |
60 | | - login username |
| 59 | + login(username) |
61 | 60 |
|
62 | 61 | then: |
63 | | - pageSource.contains('accountLocked') |
| 62 | + waitFor { pageSource.contains('accountLocked') } |
64 | 63 |
|
65 | 64 | // reset |
66 | 65 | when: |
67 | | - setUserProperty username, 'accountLocked', false |
| 66 | + setUserProperty(username, 'accountLocked', false) |
68 | 67 |
|
69 | 68 | then: |
70 | | - 'false' == getUserProperty(username, 'accountLocked') |
| 69 | + getUserProperty(username, 'accountLocked') == 'false' |
71 | 70 | } |
72 | 71 |
|
73 | 72 | void 'disable account'() { |
74 | 73 | given: |
75 | | - String username = 'admin' |
| 74 | + def username = 'admin' |
76 | 75 |
|
77 | 76 | when: |
78 | | - login username |
| 77 | + login(username) |
79 | 78 |
|
80 | 79 | then: |
81 | | - at IndexPage |
| 80 | + at(IndexPage) |
82 | 81 |
|
83 | 82 | when: |
84 | | - go 'secure-annotated' |
| 83 | + go('secure-annotated') |
85 | 84 |
|
86 | 85 | then: |
87 | | - pageSource.contains('you have ROLE_ADMIN') |
| 86 | + waitFor { pageSource.contains('you have ROLE_ADMIN') } |
88 | 87 |
|
89 | 88 | when: |
90 | 89 | logout() |
91 | 90 |
|
92 | 91 | then: |
93 | | - 'true' == getUserProperty(username, 'enabled') |
| 92 | + getUserProperty(username, 'enabled') == 'true' |
94 | 93 |
|
95 | 94 | when: |
96 | | - setUserProperty username, 'enabled', false |
| 95 | + setUserProperty(username, 'enabled', false) |
97 | 96 |
|
98 | 97 | then: |
99 | | - 'false' == getUserProperty(username, 'enabled') |
| 98 | + getUserProperty(username, 'enabled') == 'false' |
100 | 99 |
|
101 | 100 | when: |
102 | | - login username |
| 101 | + login(username) |
103 | 102 |
|
104 | 103 | then: |
105 | | - pageSource.contains('accountDisabled') |
| 104 | + waitFor { pageSource.contains('accountDisabled') } |
106 | 105 |
|
107 | 106 | // reset |
108 | 107 | when: |
109 | | - setUserProperty username, 'enabled', true |
| 108 | + setUserProperty(username, 'enabled', true) |
110 | 109 |
|
111 | 110 | then: |
112 | | - 'true' == getUserProperty(username, 'enabled') |
| 111 | + getUserProperty(username, 'enabled') == 'true' |
113 | 112 | } |
114 | 113 |
|
115 | 114 | void 'expire account'() { |
116 | 115 | given: |
117 | | - String username = 'admin' |
| 116 | + def username = 'admin' |
118 | 117 |
|
119 | 118 | when: |
120 | | - login username |
| 119 | + login(username) |
121 | 120 |
|
122 | 121 | then: |
123 | | - at IndexPage |
| 122 | + at(IndexPage) |
124 | 123 |
|
125 | 124 | when: |
126 | | - go 'secure-annotated' |
| 125 | + go('secure-annotated') |
127 | 126 |
|
128 | 127 | then: |
129 | | - pageSource.contains('you have ROLE_ADMIN') |
| 128 | + waitFor { pageSource.contains('you have ROLE_ADMIN') } |
130 | 129 |
|
131 | 130 | when: |
132 | 131 | logout() |
133 | 132 |
|
134 | 133 | then: |
135 | | - 'false' == getUserProperty(username, 'accountExpired') |
| 134 | + getUserProperty(username, 'accountExpired') == 'false' |
136 | 135 |
|
137 | 136 | when: |
138 | | - setUserProperty username, 'accountExpired', true |
| 137 | + setUserProperty(username, 'accountExpired', true) |
139 | 138 |
|
140 | 139 | then: |
141 | | - 'true' == getUserProperty(username, 'accountExpired') |
| 140 | + getUserProperty(username, 'accountExpired') == 'true' |
142 | 141 |
|
143 | 142 | when: |
144 | | - login username |
| 143 | + login(username) |
145 | 144 |
|
146 | 145 | then: |
147 | | - pageSource.contains('accountExpired') |
| 146 | + waitFor { pageSource.contains('accountExpired') } |
148 | 147 |
|
149 | 148 | // reset |
150 | 149 | when: |
151 | | - setUserProperty username, 'accountExpired', false |
| 150 | + setUserProperty(username, 'accountExpired', false) |
152 | 151 |
|
153 | 152 | then: |
154 | | - 'false' == getUserProperty(username, 'accountExpired') |
| 153 | + getUserProperty(username, 'accountExpired') == 'false' |
155 | 154 | } |
156 | 155 |
|
157 | 156 | void 'expire password'() { |
158 | 157 | given: |
159 | | - String username = 'admin' |
| 158 | + def username = 'admin' |
160 | 159 |
|
161 | 160 | when: |
162 | | - login username |
| 161 | + login(username) |
163 | 162 |
|
164 | 163 | then: |
165 | | - at IndexPage |
| 164 | + at(IndexPage) |
166 | 165 |
|
167 | 166 | when: |
168 | | - go 'secure-annotated' |
| 167 | + go('secure-annotated') |
169 | 168 |
|
170 | 169 | then: |
171 | | - pageSource.contains('you have ROLE_ADMIN') |
| 170 | + waitFor { pageSource.contains('you have ROLE_ADMIN') } |
172 | 171 |
|
173 | 172 | when: |
174 | 173 | logout() |
175 | 174 |
|
176 | 175 | then: |
177 | | - 'false' == getUserProperty(username, 'passwordExpired') |
| 176 | + getUserProperty(username, 'passwordExpired') == 'false' |
178 | 177 |
|
179 | 178 | when: |
180 | | - setUserProperty username, 'passwordExpired', true |
| 179 | + setUserProperty(username, 'passwordExpired', true) |
181 | 180 |
|
182 | 181 | then: |
183 | | - 'true' == getUserProperty(username, 'passwordExpired') |
| 182 | + getUserProperty(username, 'passwordExpired') == 'true' |
184 | 183 |
|
185 | 184 | when: |
186 | | - login username |
| 185 | + login(username) |
187 | 186 |
|
188 | 187 | then: |
189 | | - pageSource.contains('passwordExpired') |
| 188 | + waitFor { pageSource.contains('passwordExpired') } |
190 | 189 |
|
191 | 190 | // reset |
192 | 191 | when: |
193 | | - setUserProperty username, 'passwordExpired', false |
| 192 | + setUserProperty(username, 'passwordExpired', false) |
194 | 193 |
|
195 | 194 | then: |
196 | | - 'false' == getUserProperty(username, 'passwordExpired') |
| 195 | + getUserProperty(username, 'passwordExpired') == 'false' |
197 | 196 | } |
198 | 197 |
|
199 | 198 | 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") |
201 | 200 | } |
202 | 201 | } |
0 commit comments