@@ -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,20 @@ suite(
5988 }
6089 } )
6190
91+ it ( 'can remove authentication handler' , async function ( ) {
92+ await driver . network ( ) . removeAuthenticationHandler ( 10 )
93+
94+ try {
95+ await driver . get ( Pages . basicAuth )
96+ await driver . wait ( until . elementLocated ( By . css ( 'pre' ) ) )
97+ assert . fail ( 'Page should not be loaded' )
98+ } catch ( e ) {
99+ assert . strictEqual ( e . name , 'UnexpectedAlertOpenError' )
100+ }
101+ } )
102+
62103 it ( 'can clear authentication handlers' , async function ( ) {
63- await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' )
104+ await driver . network ( ) . addAuthenticationHandler ( 'genie' , 'bottle' , 'basicAuth' )
64105
65106 await driver . network ( ) . addAuthenticationHandler ( 'bottle' , 'genie' )
66107
0 commit comments