@@ -45,6 +45,35 @@ suite(
4545 assert . equal ( source . includes ( 'Access granted' ) , true )
4646 } )
4747
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+
4877 it ( 'can remove authentication handler' , async function ( ) {
4978 const id = await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' )
5079
@@ -59,8 +88,17 @@ suite(
5988 }
6089 } )
6190
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+
62100 it ( 'can clear authentication handlers' , async function ( ) {
63- await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' )
101+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
64102
65103 await driver . network ( ) . addAuthenticationHandler ( 'bottle' , 'genie' )
66104
0 commit comments