Skip to content

Commit c6987fd

Browse files
committed
Skip x509 tests when modules is not installed.
1 parent 451b09d commit c6987fd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/api/authn/webid-tls.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ function getCertificateViaHeader (req) {
7272
}
7373

7474
// Parse and convert the certificate to the format the webid library expects
75-
if (!x509) x509 = require('x509')
75+
if (!x509) {
76+
try {
77+
x509 = require('x509')
78+
} catch (e) {
79+
x509 = { parseCert: () => { throw new Error() } }
80+
}
81+
}
7682
try {
7783
const { publicKey, extensions } = x509.parseCert(rawCertificate)
7884
return {

test/integration/acl-tls-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,14 @@ describe('ACL with WebID+TLS', function () {
10731073
})
10741074

10751075
describe('ACL with WebID through X-SSL-Cert', function () {
1076+
let hasX509
1077+
try {
1078+
require('x509')
1079+
hasX509 = true
1080+
} catch (error) {
1081+
hasX509 = false
1082+
}
1083+
10761084
var ldpHttpsServer
10771085
before(function (done) {
10781086
const ldp = ldnode.createServer({
@@ -1122,10 +1130,12 @@ describe('ACL with WebID through X-SSL-Cert', function () {
11221130
before(prepareRequest(escapedCert, res => { response = res }))
11231131

11241132
it('should return 200', function () {
1133+
hasX509 || this.skip()
11251134
assert.propertyVal(response, 'statusCode', 200)
11261135
})
11271136

11281137
it('should set the User header', function () {
1138+
hasX509 || this.skip()
11291139
assert.propertyVal(response.headers, 'user', 'https://user1.databox.me/profile/card#me')
11301140
})
11311141
})

0 commit comments

Comments
 (0)