mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(test): use demo app to test username-password flow in integration test (#1635)
This commit is contained in:
parent
0b2bfb1f2e
commit
a258587b4e
2 changed files with 9 additions and 8 deletions
|
@ -1,7 +1,8 @@
|
||||||
|
import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
|
||||||
import { getEnv } from '@silverhand/essentials';
|
import { getEnv } from '@silverhand/essentials';
|
||||||
|
|
||||||
export const logtoUrl = getEnv('LOGTO_URL');
|
export const logtoUrl = getEnv('LOGTO_URL');
|
||||||
|
|
||||||
export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`;
|
export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`;
|
||||||
|
|
||||||
export const redirectUri = `${logtoUrl}/console/callback`;
|
export const demoAppRedirectUri = `${logtoUrl}/${demoAppApplicationId}`;
|
||||||
|
|
|
@ -5,12 +5,12 @@ import {
|
||||||
generateSignInUri,
|
generateSignInUri,
|
||||||
verifyAndParseCodeFromCallbackUri,
|
verifyAndParseCodeFromCallbackUri,
|
||||||
} from '@logto/js';
|
} from '@logto/js';
|
||||||
import { adminConsoleApplicationId } from '@logto/schemas/lib/seeds';
|
import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
|
||||||
import got from 'got/dist/source';
|
import got from 'got/dist/source';
|
||||||
|
|
||||||
import api from '@/api';
|
import api from '@/api';
|
||||||
|
|
||||||
import { discoveryUrl, logtoUrl, redirectUri } from '../src/constants';
|
import { discoveryUrl, logtoUrl, demoAppRedirectUri } from '../src/constants';
|
||||||
import { LogtoContext } from '../src/logto-context';
|
import { LogtoContext } from '../src/logto-context';
|
||||||
import { extractCookie } from '../src/utils';
|
import { extractCookie } from '../src/utils';
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ describe('username and password flow', () => {
|
||||||
it('should visit authorization endpoint and get interaction cookie', async () => {
|
it('should visit authorization endpoint and get interaction cookie', async () => {
|
||||||
const signInUri = generateSignInUri({
|
const signInUri = generateSignInUri({
|
||||||
authorizationEndpoint: logtoContext.authorizationEndpoint,
|
authorizationEndpoint: logtoContext.authorizationEndpoint,
|
||||||
clientId: adminConsoleApplicationId,
|
clientId: demoAppApplicationId,
|
||||||
redirectUri,
|
redirectUri: demoAppRedirectUri,
|
||||||
codeChallenge: logtoContext.codeChallenge,
|
codeChallenge: logtoContext.codeChallenge,
|
||||||
state: logtoContext.state,
|
state: logtoContext.state,
|
||||||
});
|
});
|
||||||
|
@ -154,7 +154,7 @@ describe('username and password flow', () => {
|
||||||
|
|
||||||
const authorizationCode = verifyAndParseCodeFromCallbackUri(
|
const authorizationCode = verifyAndParseCodeFromCallbackUri(
|
||||||
callbackUri,
|
callbackUri,
|
||||||
redirectUri,
|
demoAppRedirectUri,
|
||||||
logtoContext.state
|
logtoContext.state
|
||||||
);
|
);
|
||||||
expect(authorizationCode).toBeTruthy();
|
expect(authorizationCode).toBeTruthy();
|
||||||
|
@ -165,9 +165,9 @@ describe('username and password flow', () => {
|
||||||
it('should fetch token by authorization code', async () => {
|
it('should fetch token by authorization code', async () => {
|
||||||
const token = await fetchTokenByAuthorizationCode(
|
const token = await fetchTokenByAuthorizationCode(
|
||||||
{
|
{
|
||||||
clientId: adminConsoleApplicationId,
|
clientId: demoAppApplicationId,
|
||||||
tokenEndpoint: logtoContext.tokenEndpoint,
|
tokenEndpoint: logtoContext.tokenEndpoint,
|
||||||
redirectUri,
|
redirectUri: demoAppRedirectUri,
|
||||||
codeVerifier: logtoContext.codeVerifier,
|
codeVerifier: logtoContext.codeVerifier,
|
||||||
code: logtoContext.authorizationCode,
|
code: logtoContext.authorizationCode,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue