Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions src/test/5.0.0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const TestIntrospectionRequest = require('../server/lib/test/TestIntrospectionRequest.js');
const moment = require('../server/node_modules/moment');

class Test_5_0_0 extends TestIntrospectionRequest {
constructor(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
) {
super(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
);
this.num = '5.0.0';
this.description = 'request correct, token valid';
this.validation = 'self';
}
async exec() {
this.introspectionrequest.client_id = config_rp.client_id;
this.introspectionrequest.code = this.authresponse.code;
this.introspectionrequest.code_verifier = this.authrequest.code_verifier;
this.introspectionrequest.grant_type = 'authorization_code';
this.introspectionrequest.client_assertion_type =
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
this.introspectionrequest.redirect_uri = this.authrequest.redirect_uri;
this.introspectionrequest.endpoint =
this.metadata.configuration.introspection_endpoint;

const config_key = fs.readFileSync(
path.resolve(__dirname, '../config/spid-oidc-check-op-sig.key')
);
const keystore = jose.JWK.createKeyStore();

let key = await keystore.add(config_key, 'pem');

let header = {};

let iat = moment();
let exp = iat.clone().add(15, 'm');

let payload = JSON.stringify({
jti: Utility.getUUID(),
iss: this.introspectionrequest.client_id,
aud: this.metadata.configuration.introspection_endpoint,
iat: iat.unix(),
exp: exp.unix(),
sub: this.introspectionrequest.client_id,
});

this.introspectionrequest.client_assertion = await jose.JWS.createSign(
{
format: 'compact',
alg: 'RS256',
fields: { ...header },
},
key
)
.update(payload)
.final();
}
}

module.exports = Test_5_0_0;
78 changes: 78 additions & 0 deletions src/test/5.0.1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const TestIntrospectionRequest = require('../server/lib/test/TestIntrospectionRequest.js');
const moment = require('../server/node_modules/moment');

class Test_5_0_1 extends TestIntrospectionRequest {
constructor(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
) {
super(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
);
this.num = '5.0.1';
this.description = 'request correct, token expired';
this.validation = 'self';
}
async exec() {
this.introspectionrequest.client_id = config_rp.client_id;
this.introspectionrequest.code = this.authresponse.code;
this.introspectionrequest.code_verifier = this.authrequest.code_verifier;
this.introspectionrequest.grant_type = 'authorization_code';
this.introspectionrequest.client_assertion_type =
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
this.introspectionrequest.redirect_uri = this.authrequest.redirect_uri;

const config_key = fs.readFileSync(
path.resolve(__dirname, '../config/spid-oidc-check-op-sig.key')
);
const keystore = jose.JWK.createKeyStore();

let key = await keystore.add(config_key, 'pem');

let header = {};

let iat = moment();
let exp = iat.clone().add(15, 'm');

let payload = JSON.stringify({
jti: Utility.getUUID(),
iss: this.introspectionrequest.client_id,
aud: this.metadata.configuration.introspection_endpoint,
iat: iat.unix(),
exp: exp.unix(),
sub: this.introspectionrequest.client_id,
});

this.introspectionrequest.client_assertion = await jose.JWS.createSign(
{
format: 'compact',
alg: 'RS256',
fields: { ...header },
},
key
)
.update(payload)
.final();
}
}

module.exports = Test_5_0_1;
78 changes: 78 additions & 0 deletions src/test/5.0.2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const TestIntrospectionRequest = require('../server/lib/test/TestIntrospectionRequest.js');
const moment = require('../server/node_modules/moment');

class Test_5_0_2 extends TestIntrospectionRequest {
constructor(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
) {
super(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
);
this.num = '5.0.2';
this.description = 'request correct, token revoked';
this.validation = 'self';
}
async exec() {
this.introspectionrequest.client_id = config_rp.client_id;
this.introspectionrequest.code = this.authresponse.code;
this.introspectionrequest.code_verifier = this.authrequest.code_verifier;
this.introspectionrequest.grant_type = 'authorization_code';
this.introspectionrequest.client_assertion_type =
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
this.introspectionrequest.redirect_uri = this.authrequest.redirect_uri;

const config_key = fs.readFileSync(
path.resolve(__dirname, '../config/spid-oidc-check-op-sig.key')
);
const keystore = jose.JWK.createKeyStore();

let key = await keystore.add(config_key, 'pem');

let header = {};

let iat = moment();
let exp = iat.clone().add(15, 'm');

let payload = JSON.stringify({
jti: Utility.getUUID(),
iss: this.introspectionrequest.client_id,
aud: this.metadata.configuration.introspection_endpoint,
iat: iat.unix(),
exp: exp.unix(),
sub: this.introspectionrequest.client_id,
});

this.introspectionrequest.client_assertion = await jose.JWS.createSign(
{
format: 'compact',
alg: 'RS256',
fields: { ...header },
},
key
)
.update(payload)
.final();
}
}

module.exports = Test_5_0_2;
45 changes: 45 additions & 0 deletions src/test/5.1.0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const TestIntrospectionRequest = require('../server/lib/test/TestIntrospectionRequest.js');
const moment = require('../server/node_modules/moment');

class Test_5_1_0 extends TestIntrospectionRequest {
constructor(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
) {
super(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
);
this.num = '5.1.0';
this.description =
'Wrong Introspection Request: the request is sent using HTTP method different from POST';
this.validation = 'self';
}
async exec() {
this.notes = this.introspectionrequest.method;
if (this.notes != 'POST') {
throw 'introspection request is sent using HTTP method different from POST';
}
return true;
}
}

module.exports = Test_5_1_0;
69 changes: 69 additions & 0 deletions src/test/5.1.1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const TestIntrospectionRequest = require('../server/lib/test/TestIntrospectionRequest.js');
const moment = require('../server/node_modules/moment');

class Test_5_1_1 extends TestIntrospectionRequest {
constructor(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
) {
super(
metadata,
authrequest,
authresponse,
tokenrequest,
tokenresponse,
refreshtokenrequest,
refreshtokenresponse,
userinforequest,
userinforesponse,
introspectionrequest,
introspectionresponse
);
this.num = '5.1.1';
this.description =
'Wrong Introspection Request: parameter client_assertion is not present';
this.validation = 'self';
}
async exec() {
this.introspectionrequest.client_id = config_rp.client_id;
this.introspectionrequest.code = this.authresponse.code;
this.introspectionrequest.code_verifier = this.authrequest.code_verifier;
this.introspectionrequest.grant_type = 'authorization_code';
this.introspectionrequest.client_assertion_type =
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
this.introspectionrequest.redirect_uri = this.authrequest.redirect_uri;
this.introspectionrequest.endpoint =
this.metadata.configuration.introspection_endpoint;
const config_key = fs.readFileSync(
path.resolve(__dirname, '../config/spid-oidc-check-op-sig.key')
);
const keystore = jose.JWK.createKeyStore();

let key = await keystore.add(config_key, 'pem');

let header = {};

let iat = moment();
let exp = iat.clone().add(15, 'm');

let payload = JSON.stringify({
jti: Utility.getUUID(),
iss: this.introspectionrequest.client_id,
aud: this.metadata.configuration.introspection_endpoint,
iat: iat.unix(),
exp: exp.unix(),
sub: this.introspectionrequest.client_id,
});
}
}

module.exports = Test_5_1_1;
Loading