@@ -29,6 +29,7 @@ import (
29
29
"github.com/jackc/pgx/v4"
30
30
"github.com/jackc/pgx/v4/pgxpool"
31
31
"github.com/julienschmidt/httprouter"
32
+ "golang.org/x/build/internal/access"
32
33
"golang.org/x/build/internal/criadb"
33
34
"golang.org/x/build/internal/releasetargets"
34
35
"golang.org/x/build/internal/relui/db"
@@ -844,6 +845,11 @@ func testWorkflowACL(t *testing.T, acld bool, authorized bool, wantSucceed bool)
844
845
}
845
846
s := NewServer (p , worker , nil , SiteHeader {}, nil , criadb .NewTestDatabase (memberships ))
846
847
848
+ iap := access.IAPFields {
849
+ Email : "test@google.com" ,
850
+ ID : "testid" ,
851
+ }
852
+
847
853
hourAgo := time .Now ().Add (- 1 * time .Hour )
848
854
q := db .New (p )
849
855
@@ -854,7 +860,7 @@ func testWorkflowACL(t *testing.T, acld bool, authorized bool, wantSucceed bool)
854
860
"workflow.schedule" : []string {string (ScheduleImmediate )},
855
861
}.Encode ()))
856
862
req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
857
- req = req .WithContext (context . WithValue (req .Context (), "email" , "test@google.com" ))
863
+ req = req .WithContext (access . ContextWithIAP (req .Context (), iap ))
858
864
rec := httptest .NewRecorder ()
859
865
860
866
s .createWorkflowHandler (rec , req )
@@ -892,7 +898,7 @@ func testWorkflowACL(t *testing.T, acld bool, authorized bool, wantSucceed bool)
892
898
params := httprouter.Params {{Key : "id" , Value : wfID .String ()}, {Key : "name" , Value : "beep" }}
893
899
req := httptest .NewRequest (http .MethodPost , path .Join ("/workflows/" , wfID .String (), "tasks" , "beep" , "retry" ), nil )
894
900
req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
895
- req = req .WithContext (context . WithValue (req .Context (), "email" , "test@google.com" ))
901
+ req = req .WithContext (access . ContextWithIAP (req .Context (), iap ))
896
902
rec := httptest .NewRecorder ()
897
903
898
904
s .retryTaskHandler (rec , req , params )
@@ -933,7 +939,7 @@ func testWorkflowACL(t *testing.T, acld bool, authorized bool, wantSucceed bool)
933
939
params := httprouter.Params {{Key : "id" , Value : wfID .String ()}, {Key : "name" , Value : "approve" }}
934
940
req := httptest .NewRequest (http .MethodPost , path .Join ("/workflows/" , wfID .String (), "tasks" , "approve" , "approve" ), nil )
935
941
req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
936
- req = req .WithContext (context . WithValue (req .Context (), "email" , "test@google.com" ))
942
+ req = req .WithContext (access . ContextWithIAP (req .Context (), iap ))
937
943
rec := httptest .NewRecorder ()
938
944
939
945
s .approveTaskHandler (rec , req , params )
@@ -965,7 +971,7 @@ func testWorkflowACL(t *testing.T, acld bool, authorized bool, wantSucceed bool)
965
971
params := httprouter.Params {{Key : "id" , Value : wfID .String ()}}
966
972
req := httptest .NewRequest (http .MethodPost , path .Join ("/workflows/" , wfID .String (), "stop" ), nil )
967
973
req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
968
- req = req .WithContext (context . WithValue (req .Context (), "email" , "test@google.com" ))
974
+ req = req .WithContext (access . ContextWithIAP (req .Context (), iap ))
969
975
rec := httptest .NewRecorder ()
970
976
971
977
s .stopWorkflowHandler (rec , req , params )
@@ -989,7 +995,7 @@ func testWorkflowACL(t *testing.T, acld bool, authorized bool, wantSucceed bool)
989
995
params := httprouter.Params {{Key : "id" , Value : strconv .Itoa (int (sched .ID ))}}
990
996
req := httptest .NewRequest (http .MethodPost , path .Join ("/schedules/" , strconv .Itoa (int (sched .ID )), "delete" ), nil )
991
997
req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
992
- req = req .WithContext (context . WithValue (req .Context (), "email" , "test@google.com" ))
998
+ req = req .WithContext (access . ContextWithIAP (req .Context (), iap ))
993
999
rec := httptest .NewRecorder ()
994
1000
995
1001
s .deleteScheduleHandler (rec , req , params )
0 commit comments