Fix usage of JOSE library in OIDC test as part of JOSE upgrade
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
},
|
||||
"jest": {
|
||||
"moduleNameMapper": {
|
||||
"^jose/(.*)$": "<rootDir>/../node_modules/jose/dist/node/cjs/$1"
|
||||
"^jose/(.*)$": "<rootDir>/../../../node_modules/jose/dist/node/cjs/$1"
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -13,13 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { TextDecoder, TextEncoder } from 'util';
|
||||
|
||||
// @ts-ignore
|
||||
global.TextDecoder = TextDecoder;
|
||||
global.TextEncoder = TextEncoder;
|
||||
import express from 'express';
|
||||
import { Session } from 'express-session';
|
||||
import nock from 'nock';
|
||||
import { ClientMetadata, IssuerMetadata } from 'openid-client';
|
||||
import { createOidcProvider, OidcAuthProvider } from './provider';
|
||||
import { JWT, JWK } from 'jose';
|
||||
import UnsecuredJWT from 'jose/jwt/unsecured';
|
||||
import { AuthProviderFactoryOptions } from '../types';
|
||||
import { Config } from '@backstage/config';
|
||||
import { OAuthAdapter } from '../../lib/oauth';
|
||||
@@ -71,6 +75,7 @@ describe('OidcAuthProvider', () => {
|
||||
const jwt = {
|
||||
sub: 'alice',
|
||||
iss: 'https://oidc.test',
|
||||
iat: Date.now(),
|
||||
aud: clientMetadata.clientId,
|
||||
exp: Date.now() + 10000,
|
||||
};
|
||||
@@ -79,7 +84,7 @@ describe('OidcAuthProvider', () => {
|
||||
.reply(200, issuerMetadata)
|
||||
.post('/as/token.oauth2')
|
||||
.reply(200, {
|
||||
id_token: JWT.sign(jwt, JWK.None),
|
||||
id_token: new UnsecuredJWT(jwt).encode(),
|
||||
access_token: 'test',
|
||||
authorization_signed_response_alg: 'HS256',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user