Skip to content

Commit

Permalink
Merge pull request #87 from commercelayer/update-token-iss
Browse files Browse the repository at this point in the history
Update tests with the new token iss
  • Loading branch information
marcomontalbano authored Aug 24, 2024
2 parents 58080ff + 0fe8d73 commit cd13d0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ jobs:
VITE_TEST_PROVISIONING_DOMAIN: ${{ vars.VITE_TEST_PROVISIONING_DOMAIN }}
VITE_TEST_PROVISIONING_CLIENT_ID: ${{ secrets.VITE_TEST_PROVISIONING_CLIENT_ID }}
VITE_TEST_PROVISIONING_CLIENT_SECRET: ${{ secrets.VITE_TEST_PROVISIONING_CLIENT_SECRET }}
VITE_TEST_TOKEN_ISS: ${{ vars.VITE_TEST_TOKEN_ISS }}
1 change: 1 addition & 0 deletions packages/js-auth/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ declare namespace NodeJS {
VITE_TEST_PROVISIONING_DOMAIN: string
VITE_TEST_PROVISIONING_CLIENT_ID: string
VITE_TEST_PROVISIONING_CLIENT_SECRET: string
VITE_TEST_TOKEN_ISS: string
}
}
19 changes: 10 additions & 9 deletions packages/js-auth/src/authenticate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const domain = process.env.VITE_TEST_DOMAIN
const scope = process.env.VITE_TEST_SCOPE
const username = process.env.VITE_TEST_USERNAME
const password = process.env.VITE_TEST_PASSWORD
const tokenIss = process.env.VITE_TEST_TOKEN_ISS

describe('Organization auth', () => {
it('should throw an error when the clientId is not valid.', async () => {
Expand Down Expand Up @@ -66,7 +67,7 @@ describe('Organization auth', () => {
enterprise: true,
region: 'eu-west-1'
},
iss: 'https://commercelayer.io',
iss: tokenIss,
scope: 'market:all',
test: true
}
Expand Down Expand Up @@ -114,7 +115,7 @@ describe('Organization auth', () => {
enterprise: true,
region: 'eu-west-1'
},
iss: 'https://commercelayer.io',
iss: tokenIss,
scope: 'market:all',
test: true
}
Expand Down Expand Up @@ -175,7 +176,7 @@ describe('Organization auth', () => {
geocoder_id: null,
allows_external_prices: false
},
iss: 'https://commercelayer.io',
iss: tokenIss,
scope,
test: true
}
Expand Down Expand Up @@ -247,7 +248,7 @@ describe('Organization auth', () => {
geocoder_id: null,
allows_external_prices: false
},
iss: 'https://commercelayer.io',
iss: tokenIss,
scope,
test: true
}
Expand Down Expand Up @@ -296,7 +297,7 @@ describe('Provisioning auth', () => {
typ: 'JWT'
},
payload: {
iss: 'https://commercelayer.io',
iss: tokenIss,
application: {
kind: 'user',
public: false
Expand Down Expand Up @@ -422,7 +423,7 @@ function runJWTBearerTests(
custom_claim: {
app: 'supabase'
},
iss: 'https://commercelayer.io',
iss: tokenIss,
organization: {
enterprise: true,
region: 'eu-west-1',
Expand Down Expand Up @@ -482,7 +483,7 @@ function runJWTBearerTests(
type: 'User',
id: process.env.VITE_TEST_USER_ID
},
iss: 'https://commercelayer.io',
iss: tokenIss,
organization: {
enterprise: true,
region: 'eu-west-1',
Expand Down Expand Up @@ -547,7 +548,7 @@ function runJWTBearerTests(
type: 'Customer',
id: process.env.VITE_TEST_CUSTOMER_ID
},
iss: 'https://commercelayer.io',
iss: tokenIss,
organization: {
enterprise: true,
region: 'eu-west-1',
Expand Down Expand Up @@ -622,7 +623,7 @@ function runJWTBearerTests(
first_name: 'John',
last_name: 'Doe'
},
iss: 'https://commercelayer.io',
iss: tokenIss,
organization: {
enterprise: true,
region: 'eu-west-1',
Expand Down
2 changes: 1 addition & 1 deletion packages/js-auth/src/jwtDecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface JWTBase {
rand: number
/** Issued at (seconds since Unix epoch). */
iat: number
/** Who created and signed this token (e.g. `"https://commercelayer.io"`). */
/** Who created and signed this token (e.g. `"https://auth.commercelayer.io"`). */
iss: string
}

Expand Down

0 comments on commit cd13d0b

Please sign in to comment.