Fix usage of JOSE library in OIDC test as part of JOSE upgrade

This commit is contained in:
Jonah Back
2021-01-18 14:39:53 -08:00
parent 02140eb89a
commit c43d148556
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -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',
})