1
+ <!DOCTYPE html>
2
+ < meta charset ="utf-8 ">
3
+ < title > DBSC scope specification set</ title >
4
+ < script src ="/resources/testharness.js "> </ script >
5
+ < script src ="/resources/testharnessreport.js "> </ script >
6
+ < script src ="helper.js " type ="module "> </ script >
7
+
8
+ < script type ="module ">
9
+ import { expireCookie , waitForCookie , addCookieAndSessionCleanup , setupShardedServerState , configureServer } from "./helper.js" ;
10
+
11
+ promise_test ( async t => {
12
+ await setupShardedServerState ( ) ;
13
+ const expectedCookieAndValue = "auth_cookie=abcdef0123" ;
14
+ const expectedCookieAndAttributes = `${ expectedCookieAndValue } ;Domain=${ location . hostname } ;Path=/device-bound-session-credentials` ;
15
+ addCookieAndSessionCleanup ( t , expectedCookieAndAttributes ) ;
16
+
17
+ // Configure server to set scope specification.
18
+ configureServer ( { scopeSpecificationItems : [ {
19
+ "type" : "include" ,
20
+ "domain" : location . hostname ,
21
+ "path" : "/device-bound-session-credentials/excludeInScopeSpecification/excluded_verify_authenticated.py"
22
+ } , {
23
+ "type" : "exclude" ,
24
+ "domain" : location . hostname ,
25
+ "path" : "/device-bound-session-credentials/excludeInScopeSpecification"
26
+ } , {
27
+ "type" : "include" ,
28
+ "domain" : location . hostname ,
29
+ "path" : "/device-bound-session-credentials/includeInScopeSpecification/included_verify_authenticated.py"
30
+ } , {
31
+ "type" : "exclude" ,
32
+ "domain" : location . hostname ,
33
+ "path" : "/device-bound-session-credentials/verify_authenticated.py"
34
+ } , {
35
+ "type" : "include" ,
36
+ "domain" : location . hostname ,
37
+ "path" : "/device-bound-session-credentials/verify_authenticated_alternate.py"
38
+ } , {
39
+ "type" : "include" ,
40
+ "domain" : `www1.${ location . hostname } ` ,
41
+ "path" : "/device-bound-session-credentials/verify_authenticated.py"
42
+ } , {
43
+ "type" : "exclude" ,
44
+ "domain" : `www2.${ location . hostname } ` ,
45
+ "path" : "/device-bound-session-credentials/verify_authenticated.py"
46
+ } ] } ) ;
47
+
48
+ // Prompt starting a session, and wait until registration completes.
49
+ const login_response = await fetch ( 'login.py' ) ;
50
+ assert_equals ( login_response . status , 200 ) ;
51
+ assert_true ( await waitForCookie ( expectedCookieAndValue ) ) ;
52
+
53
+ async function expireCookieAndTriggerRequest ( endpoint , expectRefresh ) {
54
+ expireCookie ( expectedCookieAndAttributes ) ;
55
+ const auth_response = await fetch ( endpoint , { credentials : "include" } ) ;
56
+ assert_equals ( auth_response . status , expectRefresh ? 200 : 401 ) ;
57
+ }
58
+
59
+ await expireCookieAndTriggerRequest ( "verify_authenticated.py" , /*expectRefresh=*/ false ) ;
60
+ await expireCookieAndTriggerRequest ( "verify_authenticated_alternate.py" , /*expectRefresh=*/ true ) ;
61
+ // This one is marked as included, but excludeInScopeSpecification/ is marked as excluded, and order matters.
62
+ await expireCookieAndTriggerRequest ( "excludeInScopeSpecification/excluded_verify_authenticated.py" , /*expectRefresh=*/ false ) ;
63
+ await expireCookieAndTriggerRequest ( "includeInScopeSpecification/included_verify_authenticated.py" , /*expectRefresh=*/ true ) ;
64
+ await expireCookieAndTriggerRequest ( `${ location . protocol } //www1.${ location . hostname } :${ location . port } /device-bound-session-credentials/verify_authenticated.py` , /*expectRefresh=*/ true ) ;
65
+ await expireCookieAndTriggerRequest ( `${ location . protocol } //www2.${ location . hostname } :${ location . port } /device-bound-session-credentials/verify_authenticated.py` , /*expectRefresh=*/ false ) ;
66
+ } , "Scope specification configuration is respected" ) ;
67
+ </ script >
0 commit comments