@@ -26,6 +26,7 @@ import AuthInfo from '../../../src/auth/auth-info.js';
26
26
use ( chaiAsPromised ) ;
27
27
28
28
const publicKey = fs . readFileSync ( 'test/fixtures/auth/jwt/public_key.pem' , 'utf8' ) ;
29
+ const publicKeyB64 = Buffer . from ( publicKey , 'utf-8' ) . toString ( 'base64' ) ;
29
30
30
31
const privateKeyEncrypted = fs . readFileSync ( 'test/fixtures/auth/jwt/private_key.pem' , 'utf8' ) ;
31
32
const decryptedPrivateKey = crypto . createPrivateKey ( {
@@ -85,7 +86,7 @@ describe('SpacecatJWTHandler', () => {
85
86
86
87
it ( 'returns null when there is no authorization header' , async ( ) => {
87
88
const context = {
88
- env : { AUTH_PUBLIC_KEY : publicKey } ,
89
+ env : { AUTH_PUBLIC_KEY_B64 : publicKeyB64 } ,
89
90
} ;
90
91
const result = await handler . checkAuth ( { } , context ) ;
91
92
@@ -96,7 +97,7 @@ describe('SpacecatJWTHandler', () => {
96
97
97
98
it ( 'returns null when "Bearer " is missing from the authorization header' , async ( ) => {
98
99
const context = {
99
- env : { AUTH_PUBLIC_KEY : publicKey } ,
100
+ env : { AUTH_PUBLIC_KEY_B64 : publicKeyB64 } ,
100
101
pathInfo : { headers : { authorization : 'some-token' } } ,
101
102
} ;
102
103
const result = await handler . checkAuth ( { } , context ) ;
@@ -108,7 +109,7 @@ describe('SpacecatJWTHandler', () => {
108
109
109
110
it ( 'returns null when the token is empty' , async ( ) => {
110
111
const context = {
111
- env : { AUTH_PUBLIC_KEY : publicKey } ,
112
+ env : { AUTH_PUBLIC_KEY_B64 : publicKeyB64 } ,
112
113
pathInfo : { headers : { authorization : 'Bearer ' } } ,
113
114
} ;
114
115
const result = await handler . checkAuth ( { } , context ) ;
@@ -123,7 +124,7 @@ describe('SpacecatJWTHandler', () => {
123
124
124
125
beforeEach ( ( ) => {
125
126
context = {
126
- env : { AUTH_PUBLIC_KEY : publicKey } ,
127
+ env : { AUTH_PUBLIC_KEY_B64 : publicKeyB64 } ,
127
128
func : { version : 'ci' } ,
128
129
log : logStub ,
129
130
} ;
0 commit comments