@@ -656,8 +656,6 @@ func TestForkTreeMergesParentOverlayWritesAndDeletes(t *testing.T) {
656656
657657func TestWriteFilePayloadTooLarge (t * testing.T ) {
658658 server := mustNewServerWithConfig (t , relayfile .NewStore (), ServerConfig {
659- JWTSecret : "dev-secret" ,
660- AcceptHS256 : true ,
661659 MaxBodyBytes : 128 ,
662660 })
663661 token := mustTestJWT (t , "dev-secret" , "ws_payload_limit" , "Worker1" , []string {"fs:write" }, time .Now ().Add (time .Hour ))
@@ -687,10 +685,7 @@ func TestWriteFilePayloadTooLarge(t *testing.T) {
687685}
688686
689687func TestBinaryEncodingRoundTripAndExport (t * testing.T ) {
690- server := mustNewServerWithConfig (t , relayfile .NewStoreWithOptions (relayfile.StoreOptions {DisableWorkers : true }), ServerConfig {
691- JWTSecret : "dev-secret" ,
692- AcceptHS256 : true ,
693- })
688+ server := mustNewServerWithConfig (t , relayfile .NewStoreWithOptions (relayfile.StoreOptions {DisableWorkers : true }), ServerConfig {})
694689 token := mustTestJWT (t , "dev-secret" , "ws_binary" , "Worker1" , []string {"fs:read" , "fs:write" }, time .Now ().Add (time .Hour ))
695690 encoded := base64 .StdEncoding .EncodeToString ([]byte {0x00 , 0x7f , 0xff , 0x10 })
696691
@@ -2326,8 +2321,6 @@ func TestInternalWebhookIngressHMAC(t *testing.T) {
23262321
23272322func TestInternalWebhookIngressPayloadTooLarge (t * testing.T ) {
23282323 server := mustNewServerWithConfig (t , relayfile .NewStore (), ServerConfig {
2329- JWTSecret : "dev-secret" ,
2330- AcceptHS256 : true ,
23312324 InternalHMACSecret : "dev-internal-secret" ,
23322325 MaxBodyBytes : 256 ,
23332326 })
@@ -4605,8 +4598,6 @@ func TestInternalIngressAppliesToFilesystemAPI(t *testing.T) {
46054598
46064599func TestRateLimitingByWorkspaceAndAgent (t * testing.T ) {
46074600 server := mustNewServerWithConfig (t , relayfile .NewStore (), ServerConfig {
4608- JWTSecret : "dev-secret" ,
4609- AcceptHS256 : true ,
46104601 InternalHMACSecret : "dev-internal-secret" ,
46114602 RateLimitMax : 2 ,
46124603 RateLimitWindow : time .Minute ,
@@ -5482,33 +5473,17 @@ func mustTestJWTWithAudience(t *testing.T, secret, workspaceID, agentName string
54825473
54835474func mustTestJWTWithAudienceClaim (t * testing.T , secret , workspaceID , agentName string , scopes []string , aud any , exp time.Time ) string {
54845475 t .Helper ()
5485- headerBytes , err := json .Marshal (map [string ]any {
5486- "alg" : "HS256" ,
5487- "typ" : "JWT" ,
5488- })
5489- if err != nil {
5490- t .Fatalf ("marshal jwt header: %v" , err )
5491- }
5492- payloadBytes , err := json .Marshal (map [string ]any {
5476+ _ = secret
5477+
5478+ return mustTestRS256JWT (t , testBearerPrivateKey , testBearerJWTKID , map [string ]any {
5479+ "wks" : workspaceID ,
54935480 "workspace_id" : workspaceID ,
5481+ "sub" : agentName ,
54945482 "agent_name" : agentName ,
54955483 "scopes" : scopes ,
54965484 "exp" : exp .Unix (),
54975485 "aud" : aud ,
54985486 })
5499- if err != nil {
5500- t .Fatalf ("marshal jwt payload: %v" , err )
5501- }
5502- h := base64 .RawURLEncoding .EncodeToString (headerBytes )
5503- p := base64 .RawURLEncoding .EncodeToString (payloadBytes )
5504- signingInput := h + "." + p
5505- sig := mustHMAC (secret , signingInput )
5506- sigBytes , err := hexToBytes (sig )
5507- if err != nil {
5508- t .Fatalf ("decode signature: %v" , err )
5509- }
5510- jwtSig := base64 .RawURLEncoding .EncodeToString (sigBytes )
5511- return signingInput + "." + jwtSig
55125487}
55135488
55145489func mustHMAC (secret , data string ) string {
@@ -5517,32 +5492,6 @@ func mustHMAC(secret, data string) string {
55175492 return fmt .Sprintf ("%x" , mac .Sum (nil ))
55185493}
55195494
5520- func hexToBytes (h string ) ([]byte , error ) {
5521- if len (h )% 2 != 0 {
5522- return nil , fmt .Errorf ("invalid hex" )
5523- }
5524- out := make ([]byte , len (h )/ 2 )
5525- for i := 0 ; i < len (h ); i += 2 {
5526- var b byte
5527- for j := 0 ; j < 2 ; j ++ {
5528- ch := h [i + j ]
5529- b <<= 4
5530- switch {
5531- case ch >= '0' && ch <= '9' :
5532- b |= ch - '0'
5533- case ch >= 'a' && ch <= 'f' :
5534- b |= ch - 'a' + 10
5535- case ch >= 'A' && ch <= 'F' :
5536- b |= ch - 'A' + 10
5537- default :
5538- return nil , fmt .Errorf ("invalid hex char" )
5539- }
5540- }
5541- out [i / 2 ] = b
5542- }
5543- return out , nil
5544- }
5545-
55465495type serverFailingAdapter struct {
55475496 provider string
55485497}
0 commit comments