@@ -11,11 +11,17 @@ import {
1111} from "./helpers/default-config" ;
1212import { FgaValidationError } from "../errors" ;
1313
14- nock . disableNetConnect ( ) ;
15-
1614describe ( "Credentials" , ( ) => {
1715 const mockTelemetryConfig : TelemetryConfiguration = new TelemetryConfiguration ( { } ) ;
1816
17+ beforeAll ( ( ) => {
18+ nock . disableNetConnect ( ) ;
19+ } ) ;
20+
21+ afterAll ( ( ) => {
22+ nock . enableNetConnect ( ) ;
23+ } ) ;
24+
1925 describe ( "Refreshing access token" , ( ) => {
2026 afterEach ( ( ) => {
2127 nock . cleanAll ( ) ;
@@ -25,49 +31,49 @@ describe("Credentials", () => {
2531 {
2632 description : "should use default scheme and token endpoint path when apiTokenIssuer has no scheme and no path" ,
2733 apiTokenIssuer : "issuer.fga.example" ,
28- expectedBaseUrl : "https://issuer.fga.example:443 " ,
34+ expectedBaseUrl : "https://issuer.fga.example" ,
2935 expectedPath : `/${ DEFAULT_TOKEN_ENDPOINT_PATH } ` ,
3036 } ,
3137 {
3238 description : "should use default token endpoint path when apiTokenIssuer has root path and no scheme" ,
3339 apiTokenIssuer : "https://issuer.fga.example/" ,
34- expectedBaseUrl : "https://issuer.fga.example:443 " ,
40+ expectedBaseUrl : "https://issuer.fga.example" ,
3541 expectedPath : `/${ DEFAULT_TOKEN_ENDPOINT_PATH } ` ,
3642 } ,
3743 {
3844 description : "should preserve custom token endpoint path when provided" ,
3945 apiTokenIssuer : "https://issuer.fga.example/some_endpoint" ,
40- expectedBaseUrl : "https://issuer.fga.example:443 " ,
46+ expectedBaseUrl : "https://issuer.fga.example" ,
4147 expectedPath : "/some_endpoint" ,
4248 } ,
4349 {
4450 description : "should preserve custom token endpoint path with nested path when provided" ,
4551 apiTokenIssuer : "https://issuer.fga.example/api/v1/oauth/token" ,
46- expectedBaseUrl : "https://issuer.fga.example:443 " ,
52+ expectedBaseUrl : "https://issuer.fga.example" ,
4753 expectedPath : "/api/v1/oauth/token" ,
4854 } ,
4955 {
5056 description : "should add https:// prefix when apiTokenIssuer has no scheme" ,
5157 apiTokenIssuer : "issuer.fga.example/some_endpoint" ,
52- expectedBaseUrl : "https://issuer.fga.example:443 " ,
58+ expectedBaseUrl : "https://issuer.fga.example" ,
5359 expectedPath : "/some_endpoint" ,
5460 } ,
5561 {
5662 description : "should preserve http:// scheme when provided" ,
5763 apiTokenIssuer : "http://issuer.fga.example/some_endpoint" ,
58- expectedBaseUrl : "http://issuer.fga.example:80 " ,
64+ expectedBaseUrl : "http://issuer.fga.example" ,
5965 expectedPath : "/some_endpoint" ,
6066 } ,
6167 {
6268 description : "should use default path when apiTokenIssuer has https:// scheme but no path" ,
6369 apiTokenIssuer : "https://issuer.fga.example" ,
64- expectedBaseUrl : "https://issuer.fga.example:443 " ,
70+ expectedBaseUrl : "https://issuer.fga.example" ,
6571 expectedPath : `/${ DEFAULT_TOKEN_ENDPOINT_PATH } ` ,
6672 } ,
6773 {
6874 description : "should preserve custom path with query parameters" ,
6975 apiTokenIssuer : "https://issuer.fga.example/some_endpoint?param=value" ,
70- expectedBaseUrl : "https://issuer.fga.example:443 " ,
76+ expectedBaseUrl : "https://issuer.fga.example" ,
7177 expectedPath : "/some_endpoint" ,
7278 queryParams : { param : "value" } ,
7379 } ,
@@ -80,19 +86,19 @@ describe("Credentials", () => {
8086 {
8187 description : "should use default path when path has multiple trailing slashes" ,
8288 apiTokenIssuer : "https://issuer.fga.example///" ,
83- expectedBaseUrl : "https://issuer.fga.example:443 " ,
89+ expectedBaseUrl : "https://issuer.fga.example" ,
8490 expectedPath : `/${ DEFAULT_TOKEN_ENDPOINT_PATH } ` ,
8591 } ,
8692 {
8793 description : "should use default path when path only consists of slashes" ,
8894 apiTokenIssuer : "https://issuer.fga.example//" ,
89- expectedBaseUrl : "https://issuer.fga.example:443 " ,
95+ expectedBaseUrl : "https://issuer.fga.example" ,
9096 expectedPath : `/${ DEFAULT_TOKEN_ENDPOINT_PATH } ` ,
9197 } ,
9298 {
9399 description : "should preserve custom path with consecutive/trailing slashes" ,
94100 apiTokenIssuer : "https://issuer.fga.example/oauth//token///" ,
95- expectedBaseUrl : "https://issuer.fga.example:443 " ,
101+ expectedBaseUrl : "https://issuer.fga.example" ,
96102 expectedPath : "/oauth//token///" ,
97103 } ,
98104 ] ) ( "$description" , async ( { apiTokenIssuer, expectedBaseUrl, expectedPath, queryParams } ) => {
@@ -163,19 +169,19 @@ describe("Credentials", () => {
163169 {
164170 description : "HTTPS scheme" ,
165171 apiTokenIssuer : "https://issuer.fga.example/some_endpoint" ,
166- expectedBaseUrl : "https://issuer.fga.example:443 " ,
172+ expectedBaseUrl : "https://issuer.fga.example" ,
167173 expectedAudience : "https://issuer.fga.example/some_endpoint/" ,
168174 } ,
169175 {
170176 description : "HTTP scheme" ,
171177 apiTokenIssuer : "http://issuer.fga.example/some_endpoint" ,
172- expectedBaseUrl : "http://issuer.fga.example:80 " ,
178+ expectedBaseUrl : "http://issuer.fga.example" ,
173179 expectedAudience : "http://issuer.fga.example/some_endpoint/" ,
174180 } ,
175181 {
176182 description : "No scheme" ,
177183 apiTokenIssuer : "issuer.fga.example/some_endpoint" ,
178- expectedBaseUrl : "https://issuer.fga.example:443 " ,
184+ expectedBaseUrl : "https://issuer.fga.example" ,
179185 expectedAudience : "https://issuer.fga.example/some_endpoint/" ,
180186 }
181187 ] ) ( "should normalize audience from apiTokenIssuer when using PrivateKeyJWT client credentials ($description)" , async ( { apiTokenIssuer, expectedBaseUrl, expectedAudience } ) => {
0 commit comments