@@ -176,7 +176,7 @@ class SiteServiceImplTest extends Specification {
176
176
177
177
def " logAboutFailedAuthentication() should call dao" () {
178
178
when :
179
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
179
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
180
180
then :
181
181
1 * suspiciousActivityDao. add(_ as SuspiciousActivity )
182
182
}
@@ -185,17 +185,29 @@ class SiteServiceImplTest extends Specification {
185
185
given :
186
186
SuspiciousActivityType expectedType = TestObjects . createAuthFailedActivityType()
187
187
when :
188
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
188
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
189
189
then :
190
190
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
191
191
assert activity?. type?. name == expectedType. name
192
192
return true
193
193
})
194
194
}
195
195
196
- def " logAboutFailedAuthentication() should assign occurred at to current date" () {
196
+ def " logAboutFailedAuthentication() should assign occurred at to current date when date was provided" () {
197
+ given :
198
+ Date expectedDate = new Date () - 100 ;
199
+ when :
200
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , expectedDate)
201
+ then :
202
+ 1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
203
+ assert DateUtils . roughlyEqual(activity?. occurredAt, expectedDate)
204
+ return true
205
+ })
206
+ }
207
+
208
+ def " logAboutFailedAuthentication() should assign occurred at to current date when date wasn't provided" () {
197
209
when :
198
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
210
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
199
211
then :
200
212
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
201
213
assert DateUtils . roughlyEqual(activity?. occurredAt, new Date ())
@@ -205,14 +217,14 @@ class SiteServiceImplTest extends Specification {
205
217
206
218
def " logAboutFailedAuthentication() should throw exception when page is null" () {
207
219
when :
208
- service. logAboutFailedAuthentication(null , null , null , null , null )
220
+ service. logAboutFailedAuthentication(null , null , null , null , null , null )
209
221
then :
210
222
thrown IllegalArgumentException
211
223
}
212
224
213
225
def " logAboutFailedAuthentication() should pass page to dao" () {
214
226
when :
215
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
227
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
216
228
then :
217
229
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
218
230
assert activity?. page == TEST_PAGE
@@ -222,7 +234,7 @@ class SiteServiceImplTest extends Specification {
222
234
223
235
def " logAboutFailedAuthentication() should pass null to dao for unknown user" () {
224
236
when :
225
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
237
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
226
238
then :
227
239
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
228
240
assert activity?. user == null
@@ -234,7 +246,7 @@ class SiteServiceImplTest extends Specification {
234
246
given :
235
247
User user = TestObjects . createUser()
236
248
when :
237
- service. logAboutFailedAuthentication(TEST_PAGE , user, null , null , null )
249
+ service. logAboutFailedAuthentication(TEST_PAGE , user, null , null , null , null )
238
250
then :
239
251
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
240
252
assert activity?. user == user
@@ -244,7 +256,7 @@ class SiteServiceImplTest extends Specification {
244
256
245
257
def " logAboutFailedAuthentication() should pass ip to dao" () {
246
258
when :
247
- service. logAboutFailedAuthentication(TEST_PAGE , null , TEST_IP , null , null )
259
+ service. logAboutFailedAuthentication(TEST_PAGE , null , TEST_IP , null , null , null )
248
260
then :
249
261
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
250
262
assert activity?. ip == TEST_IP
@@ -254,7 +266,7 @@ class SiteServiceImplTest extends Specification {
254
266
255
267
def " logAboutFailedAuthentication() should pass empty string to dao for unknown ip" () {
256
268
when :
257
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
269
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
258
270
then :
259
271
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
260
272
assert activity?. ip?. empty
@@ -264,7 +276,7 @@ class SiteServiceImplTest extends Specification {
264
276
265
277
def " logAboutFailedAuthentication() should pass referer to dao" () {
266
278
when :
267
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , TEST_REFERER_PAGE , null )
279
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , TEST_REFERER_PAGE , null , null )
268
280
then :
269
281
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
270
282
assert activity?. refererPage == TEST_REFERER_PAGE
@@ -274,7 +286,7 @@ class SiteServiceImplTest extends Specification {
274
286
275
287
def " logAboutFailedAuthentication() should pass empty string to dao for unknown referer" () {
276
288
when :
277
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
289
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
278
290
then :
279
291
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
280
292
assert activity?. refererPage?. empty
@@ -284,7 +296,7 @@ class SiteServiceImplTest extends Specification {
284
296
285
297
def " logAboutFailedAuthentication() should pass user agent to dao" () {
286
298
when :
287
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , TEST_USER_AGENT )
299
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , TEST_USER_AGENT , null )
288
300
then :
289
301
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
290
302
assert activity?. userAgent == TEST_USER_AGENT
@@ -294,7 +306,7 @@ class SiteServiceImplTest extends Specification {
294
306
295
307
def " logAboutFailedAuthentication() should pass empty string to dao for unknown user agent" () {
296
308
when :
297
- service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null )
309
+ service. logAboutFailedAuthentication(TEST_PAGE , null , null , null , null , null )
298
310
then :
299
311
1 * suspiciousActivityDao. add({ SuspiciousActivity activity ->
300
312
assert activity?. userAgent?. empty
0 commit comments