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';
|
||||
|
||||
export const logtoUrl = getEnv('LOGTO_URL');
|
||||
|
||||
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,
|
||||
verifyAndParseCodeFromCallbackUri,
|
||||
} from '@logto/js';
|
||||
import { adminConsoleApplicationId } from '@logto/schemas/lib/seeds';
|
||||
import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
|
||||
import got from 'got/dist/source';
|
||||
|
||||
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 { extractCookie } from '../src/utils';
|
||||
|
||||
|
@ -34,8 +34,8 @@ describe('username and password flow', () => {
|
|||
it('should visit authorization endpoint and get interaction cookie', async () => {
|
||||
const signInUri = generateSignInUri({
|
||||
authorizationEndpoint: logtoContext.authorizationEndpoint,
|
||||
clientId: adminConsoleApplicationId,
|
||||
redirectUri,
|
||||
clientId: demoAppApplicationId,
|
||||
redirectUri: demoAppRedirectUri,
|
||||
codeChallenge: logtoContext.codeChallenge,
|
||||
state: logtoContext.state,
|
||||
});
|
||||
|
@ -154,7 +154,7 @@ describe('username and password flow', () => {
|
|||
|
||||
const authorizationCode = verifyAndParseCodeFromCallbackUri(
|
||||
callbackUri,
|
||||
redirectUri,
|
||||
demoAppRedirectUri,
|
||||
logtoContext.state
|
||||
);
|
||||
expect(authorizationCode).toBeTruthy();
|
||||
|
@ -165,9 +165,9 @@ describe('username and password flow', () => {
|
|||
it('should fetch token by authorization code', async () => {
|
||||
const token = await fetchTokenByAuthorizationCode(
|
||||
{
|
||||
clientId: adminConsoleApplicationId,
|
||||
clientId: demoAppApplicationId,
|
||||
tokenEndpoint: logtoContext.tokenEndpoint,
|
||||
redirectUri,
|
||||
redirectUri: demoAppRedirectUri,
|
||||
codeVerifier: logtoContext.codeVerifier,
|
||||
code: logtoContext.authorizationCode,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue