|
1 | 1 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
2 | | -import { |
3 | | - authScopeResponse, |
4 | | - AuthAdministrativeScopes, |
5 | | - AuthStandardClientScopes, |
6 | | -} from "@t3tools/contracts"; |
| 2 | +import { authScopeResponse, AuthStandardClientScopes } from "@t3tools/contracts"; |
7 | 3 | import { expect, it } from "@effect/vitest"; |
8 | 4 | import * as Effect from "effect/Effect"; |
9 | 5 | import * as Layer from "effect/Layer"; |
@@ -103,7 +99,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => { |
103 | 99 | const authenticated = yield* serverAuth.authenticateHttpRequest(request); |
104 | 100 | expect(devExchange.cookieName).toMatch(/^t3_dev_session_/); |
105 | 101 | expect(devExchange.expireNormalCookie).toBe(true); |
106 | | - expect(devExchange.response).toMatchObject(authScopeResponse(AuthAdministrativeScopes)); |
| 102 | + expect(devExchange.response).toMatchObject(authScopeResponse(AuthStandardClientScopes)); |
107 | 103 | expect(authenticated.scopes).toEqual(["orchestration:read"]); |
108 | 104 | }).pipe( |
109 | 105 | Effect.provide( |
@@ -253,7 +249,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => { |
253 | 249 | expect((yield* Effect.flip(sessions.verify(token)))._tag).toBe("SessionTokenRevokedError"); |
254 | 250 | expect( |
255 | 251 | (yield* serverAuth.createBrowserSession(recovery.credential, requestMetadata)).response, |
256 | | - ).toMatchObject({ authenticated: true, ...authScopeResponse(AuthAdministrativeScopes) }); |
| 252 | + ).toMatchObject({ authenticated: true, ...authScopeResponse(AuthStandardClientScopes) }); |
257 | 253 | }).pipe( |
258 | 254 | Effect.provide( |
259 | 255 | layerEnvironmentAuth({ |
@@ -362,7 +358,9 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => { |
362 | 358 | it.effect("preserves pairing grants after rejecting scopes they do not grant", () => |
363 | 359 | Effect.gen(function* () { |
364 | 360 | const serverAuth = yield* EnvironmentAuth.EnvironmentAuth; |
365 | | - const pairingCredential = yield* serverAuth.issuePairingCredential(); |
| 361 | + const pairingCredential = yield* serverAuth.issuePairingCredential({ |
| 362 | + scopes: ["orchestration:read", "orchestration:operate"], |
| 363 | + }); |
366 | 364 |
|
367 | 365 | const error = yield* serverAuth |
368 | 366 | .exchangeBootstrapCredentialForAccessToken( |
@@ -514,7 +512,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => { |
514 | 512 | Effect.gen(function* () { |
515 | 513 | const serverAuth = yield* EnvironmentAuth.EnvironmentAuth; |
516 | 514 | const pairingCredential = yield* serverAuth.issuePairingCredential({ |
517 | | - scopes: AuthAdministrativeScopes, |
| 515 | + scopes: AuthStandardClientScopes, |
518 | 516 | }); |
519 | 517 | const listedPairingLinks = yield* serverAuth.listPairingLinks(); |
520 | 518 |
|
@@ -544,7 +542,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => { |
544 | 542 | makeCookieRequest(sessions.cookieName, exchanged.sessionToken), |
545 | 543 | ); |
546 | 544 |
|
547 | | - expect(verified.scopes).toEqual(AuthAdministrativeScopes); |
| 545 | + expect(verified.scopes).toEqual(AuthStandardClientScopes); |
548 | 546 | expect(verified.subject).toBe("administrative-bootstrap"); |
549 | 547 | }).pipe(Effect.provide(layerEnvironmentAuth())), |
550 | 548 | ); |
|
0 commit comments