@@ -45,6 +45,35 @@ suite(
45
45
assert . equal ( source . includes ( 'Access granted' ) , true )
46
46
} )
47
47
48
+ it ( 'can add authentication handler with filter' , async function ( ) {
49
+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
50
+ await driver . get ( Pages . basicAuth )
51
+
52
+ await driver . wait ( until . elementLocated ( By . css ( 'pre' ) ) )
53
+ let source = await driver . getPageSource ( )
54
+ assert . equal ( source . includes ( 'Access granted' ) , true )
55
+ } )
56
+
57
+ it ( 'can add multiple authentication handlers with filter' , async function ( ) {
58
+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
59
+ await driver . network ( ) . addAuthenticationHandler ( 'test' , 'test' , 'test' )
60
+ await driver . get ( Pages . basicAuth )
61
+
62
+ await driver . wait ( until . elementLocated ( By . css ( 'pre' ) ) )
63
+ let source = await driver . getPageSource ( )
64
+ assert . equal ( source . includes ( 'Access granted' ) , true )
65
+ } )
66
+
67
+ it ( 'can add multiple authentication handlers with the same filter' , async function ( ) {
68
+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
69
+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
70
+ await driver . get ( Pages . basicAuth )
71
+
72
+ await driver . wait ( until . elementLocated ( By . css ( 'pre' ) ) )
73
+ let source = await driver . getPageSource ( )
74
+ assert . equal ( source . includes ( 'Access granted' ) , true )
75
+ } )
76
+
48
77
it ( 'can remove authentication handler' , async function ( ) {
49
78
const id = await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' )
50
79
@@ -59,8 +88,17 @@ suite(
59
88
}
60
89
} )
61
90
91
+ it ( 'throws an error when remove authentication handler that does not exist' , async function ( ) {
92
+ try {
93
+ await driver . network ( ) . removeAuthenticationHandler ( 10 )
94
+ assert . fail ( 'Expected error not thrown. Non-existent handler cannot be removed' )
95
+ } catch ( e ) {
96
+ assert . strictEqual ( e . message , 'Callback with id 10 not found' )
97
+ }
98
+ } )
99
+
62
100
it ( 'can clear authentication handlers' , async function ( ) {
63
- await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' )
101
+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
64
102
65
103
await driver . network ( ) . addAuthenticationHandler ( 'bottle' , 'genie' )
66
104
0 commit comments