@@ -1283,7 +1283,6 @@ mod test {
1283
1283
// ));
1284
1284
}
1285
1285
1286
-
1287
1286
#[ tokio:: test]
1288
1287
async fn test_allowed_keys_for_guest ( ) {
1289
1288
let app_guard = setup_dummy_app ( ) . await ;
@@ -1292,7 +1291,6 @@ mod test {
1292
1291
let allowed_keys = GET_ANALYTICS_ALLOWED_KEYS . clone ( ) ;
1293
1292
let base_datehour = DateHour :: from_ymdh ( 2022 , 1 , 17 , 14 ) ;
1294
1293
1295
-
1296
1294
// Test for each allowed key
1297
1295
// Country
1298
1296
{
@@ -1310,7 +1308,14 @@ mod test {
1310
1308
country : Some ( "Bulgaria" . to_string ( ) ) ,
1311
1309
..Default :: default ( )
1312
1310
} ;
1313
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await ;
1311
+ let res = get_analytics (
1312
+ Extension ( app. clone ( ) ) ,
1313
+ None ,
1314
+ Extension ( allowed_keys. clone ( ) ) ,
1315
+ None ,
1316
+ Qs ( query) ,
1317
+ )
1318
+ . await ;
1314
1319
assert ! ( res. is_ok( ) ) ;
1315
1320
}
1316
1321
// Ad Slot Type
@@ -1329,7 +1334,14 @@ mod test {
1329
1334
ad_slot_type : Some ( "legacy_300x100" . to_string ( ) ) ,
1330
1335
..Default :: default ( )
1331
1336
} ;
1332
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await ;
1337
+ let res = get_analytics (
1338
+ Extension ( app. clone ( ) ) ,
1339
+ None ,
1340
+ Extension ( allowed_keys. clone ( ) ) ,
1341
+ None ,
1342
+ Qs ( query) ,
1343
+ )
1344
+ . await ;
1333
1345
assert ! ( res. is_ok( ) ) ;
1334
1346
}
1335
1347
// Test each not allowed key
@@ -1349,7 +1361,15 @@ mod test {
1349
1361
campaign_id : Some ( DUMMY_CAMPAIGN . id ) ,
1350
1362
..Default :: default ( )
1351
1363
} ;
1352
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should be an error" ) ;
1364
+ let res = get_analytics (
1365
+ Extension ( app. clone ( ) ) ,
1366
+ None ,
1367
+ Extension ( allowed_keys. clone ( ) ) ,
1368
+ None ,
1369
+ Qs ( query) ,
1370
+ )
1371
+ . await
1372
+ . expect_err ( "should be an error" ) ;
1353
1373
assert_eq ! (
1354
1374
ResponseError :: Forbidden ( "Disallowed query key `campaignId`" . into( ) ) ,
1355
1375
res,
@@ -1371,7 +1391,15 @@ mod test {
1371
1391
ad_unit : Some ( DUMMY_IPFS [ 0 ] ) ,
1372
1392
..Default :: default ( )
1373
1393
} ;
1374
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should be an error" ) ;
1394
+ let res = get_analytics (
1395
+ Extension ( app. clone ( ) ) ,
1396
+ None ,
1397
+ Extension ( allowed_keys. clone ( ) ) ,
1398
+ None ,
1399
+ Qs ( query) ,
1400
+ )
1401
+ . await
1402
+ . expect_err ( "should be an error" ) ;
1375
1403
assert_eq ! (
1376
1404
ResponseError :: Forbidden ( "Disallowed query key `adUnit`" . into( ) ) ,
1377
1405
res,
@@ -1393,7 +1421,15 @@ mod test {
1393
1421
ad_slot : Some ( DUMMY_IPFS [ 1 ] ) ,
1394
1422
..Default :: default ( )
1395
1423
} ;
1396
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should be an error" ) ;
1424
+ let res = get_analytics (
1425
+ Extension ( app. clone ( ) ) ,
1426
+ None ,
1427
+ Extension ( allowed_keys. clone ( ) ) ,
1428
+ None ,
1429
+ Qs ( query) ,
1430
+ )
1431
+ . await
1432
+ . expect_err ( "should be an error" ) ;
1397
1433
assert_eq ! (
1398
1434
ResponseError :: Forbidden ( "Disallowed query key `adSlot`" . into( ) ) ,
1399
1435
res,
@@ -1415,7 +1451,15 @@ mod test {
1415
1451
advertiser : Some ( * ADVERTISER ) ,
1416
1452
..Default :: default ( )
1417
1453
} ;
1418
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should throw an error" ) ;
1454
+ let res = get_analytics (
1455
+ Extension ( app. clone ( ) ) ,
1456
+ None ,
1457
+ Extension ( allowed_keys. clone ( ) ) ,
1458
+ None ,
1459
+ Qs ( query) ,
1460
+ )
1461
+ . await
1462
+ . expect_err ( "should throw an error" ) ;
1419
1463
assert_eq ! (
1420
1464
ResponseError :: Forbidden ( "Disallowed query key `advertiser`" . into( ) ) ,
1421
1465
res,
@@ -1437,7 +1481,15 @@ mod test {
1437
1481
publisher : Some ( * PUBLISHER ) ,
1438
1482
..Default :: default ( )
1439
1483
} ;
1440
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should throw an error" ) ;
1484
+ let res = get_analytics (
1485
+ Extension ( app. clone ( ) ) ,
1486
+ None ,
1487
+ Extension ( allowed_keys. clone ( ) ) ,
1488
+ None ,
1489
+ Qs ( query) ,
1490
+ )
1491
+ . await
1492
+ . expect_err ( "should throw an error" ) ;
1441
1493
assert_eq ! (
1442
1494
ResponseError :: Forbidden ( "Disallowed query key `publisher`" . into( ) ) ,
1443
1495
res,
@@ -1459,7 +1511,15 @@ mod test {
1459
1511
hostname : Some ( "localhost" . to_string ( ) ) ,
1460
1512
..Default :: default ( )
1461
1513
} ;
1462
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should throw an error" ) ;
1514
+ let res = get_analytics (
1515
+ Extension ( app. clone ( ) ) ,
1516
+ None ,
1517
+ Extension ( allowed_keys. clone ( ) ) ,
1518
+ None ,
1519
+ Qs ( query) ,
1520
+ )
1521
+ . await
1522
+ . expect_err ( "should throw an error" ) ;
1463
1523
assert_eq ! (
1464
1524
ResponseError :: Forbidden ( "Disallowed query key `hostname`" . into( ) ) ,
1465
1525
res,
@@ -1481,7 +1541,15 @@ mod test {
1481
1541
os_name : Some ( OperatingSystem :: map_os ( "Windows" ) ) ,
1482
1542
..Default :: default ( )
1483
1543
} ;
1484
- let res = get_analytics ( Extension ( app. clone ( ) ) , None , Extension ( allowed_keys. clone ( ) ) , None , Qs ( query) ) . await . expect_err ( "should throw an error" ) ;
1544
+ let res = get_analytics (
1545
+ Extension ( app. clone ( ) ) ,
1546
+ None ,
1547
+ Extension ( allowed_keys. clone ( ) ) ,
1548
+ None ,
1549
+ Qs ( query) ,
1550
+ )
1551
+ . await
1552
+ . expect_err ( "should throw an error" ) ;
1485
1553
assert_eq ! (
1486
1554
ResponseError :: Forbidden ( "Disallowed query key `osName`" . into( ) ) ,
1487
1555
res,
0 commit comments