@@ -6,6 +6,7 @@ import { createServer, Server } from 'node:http';
66import path from 'node:path' ;
77import { getDefaultCssVariables , getPorts , instantiateFromConfig } from '../util/ServerUtil' ;
88import { findTokenEndpoint , noTokenFetch , generateCredentials } from '../util/UmaUtil' ;
9+ import { generateCssClientCredentials , generateCssClientCredentialsToken } from '../util/Util' ;
910
1011const [ cssPort , umaPort ] = getPorts ( 'OIDC' ) ;
1112const idpPort = umaPort + 100 ;
@@ -21,7 +22,7 @@ describe('A server supporting OIDC tokens', (): void => {
2122 const oidcFormat = 'http://openid.net/specs/openid-connect-core-1_0.html#IDToken' ;
2223
2324 beforeAll ( async ( ) : Promise < void > => {
24- setGlobalLoggerFactory ( new WinstonLoggerFactory ( 'off ' ) ) ;
25+ setGlobalLoggerFactory ( new WinstonLoggerFactory ( 'info ' ) ) ;
2526
2627 umaApp = await instantiateFromConfig (
2728 'urn:uma:default:App' ,
@@ -229,8 +230,7 @@ describe('A server supporting OIDC tokens', (): void => {
229230
230231 describe ( 'accessing a resource using a Solid OIDC token.' , ( ) : void => {
231232 const resource = `http://localhost:${ cssPort } /alice/solid` ;
232- // Using dummy server so we can spoof WebID
233- const alice = idpUrl + 'alice/profile/card#me' ;
233+ const alice = `http://localhost:${ cssPort } /alice/profile/card#me` ;
234234 const policy = `
235235 @prefix ex: <http://example.org/>.
236236 @prefix odrl: <http://www.w3.org/ns/odrl/2/> .
@@ -254,30 +254,21 @@ describe('A server supporting OIDC tokens', (): void => {
254254 expect ( response . status ) . toBe ( 201 ) ;
255255 } ) ;
256256
257- // TODO: might want a test with an actual token from the RS IDP, but would require more steps and dependencies
258257 it ( 'can get an access token.' , async ( ) : Promise < void > => {
259258 const { as_uri, ticket } = await noTokenFetch ( resource , {
260259 method : 'PUT' ,
261260 headers : { 'content-type' : 'text/plain' } ,
262261 body : 'hello' ,
263262 } ) ;
264263 const endpoint = await findTokenEndpoint ( as_uri ) ;
265-
266- const jwk = await importJWK ( privateKey , privateKey . alg ) ;
267- const jwt = await new SignJWT ( { webid : alice } )
268- . setSubject ( alice )
269- . setProtectedHeader ( { alg : privateKey . alg , kid : privateKey . kid } )
270- . setIssuedAt ( )
271- . setIssuer ( idpUrl )
272- . setAudience ( [ 'solid' , `http://localhost:${ umaPort } /uma` ] )
273- . setJti ( randomUUID ( ) )
274- . setExpirationTime ( Date . now ( ) + 5000 )
275- . sign ( jwk ) ;
264+ const credentials = await generateCssClientCredentials (
265+ `http://localhost:${ cssPort } /` , 'alice@example.org' , 'abc123' , alice ) ;
266+ const token = await generateCssClientCredentialsToken ( `http://localhost:${ cssPort } /` , credentials . id , credentials . secret ) ;
276267
277268 const content : Record < string , string > = {
278269 grant_type : 'urn:ietf:params:oauth:grant-type:uma-ticket' ,
279270 ticket : ticket ,
280- claim_token : jwt ,
271+ claim_token : token ,
281272 claim_token_format : oidcFormat ,
282273 } ;
283274
@@ -332,6 +323,7 @@ describe('A server supporting OIDC tokens', (): void => {
332323 } ) ;
333324 const endpoint = await findTokenEndpoint ( as_uri ) ;
334325
326+ // Not using client credentials as we can't set the client_id that way (or I forgot how to do it)
335327 const jwk = await importJWK ( privateKey , privateKey . alg ) ;
336328 const jwt = await new SignJWT ( { webid : bob , azp : client } )
337329 . setSubject ( bob )
0 commit comments