|
| 1 | +// Copyright Joyent, Inc. and other Node contributors. |
| 2 | +// |
| 3 | +// Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | +// copy of this software and associated documentation files (the |
| 5 | +// "Software"), to deal in the Software without restriction, including |
| 6 | +// without limitation the rights to use, copy, modify, merge, publish, |
| 7 | +// distribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 | +// persons to whom the Software is furnished to do so, subject to the |
| 9 | +// following conditions: |
| 10 | +// |
| 11 | +// The above copyright notice and this permission notice shall be included |
| 12 | +// in all copies or substantial portions of the Software. |
| 13 | +// |
| 14 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 | +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 17 | +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 18 | +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 19 | +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 20 | +// USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | + |
| 22 | +'use strict'; |
| 23 | +const common = require('../common'); |
| 24 | + |
| 25 | +if (!common.hasCrypto) |
| 26 | + common.skip('missing crypto'); |
| 27 | + |
| 28 | +const assert = require('assert'); |
| 29 | +const https = require('https'); |
| 30 | +const fs = require('fs'); |
| 31 | + |
| 32 | +assert.doesNotThrow(() => |
| 33 | + https.createServer({ |
| 34 | + key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), |
| 35 | + cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`) |
| 36 | + })); |
| 37 | + |
| 38 | +assert.throws(() => |
| 39 | + https.createServer({ |
| 40 | + key: true, |
| 41 | + cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`) |
| 42 | + }), /"options\.key" must not be a boolean/); |
| 43 | + |
| 44 | +assert.throws(() => |
| 45 | + https.createServer({ |
| 46 | + key: false, |
| 47 | + cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`) |
| 48 | + }), /"options\.key" must not be a boolean/); |
| 49 | + |
| 50 | +assert.throws(() => |
| 51 | + https.createServer({ |
| 52 | + key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), |
| 53 | + cert: true |
| 54 | + }), /"options\.cert" must not be a boolean/); |
| 55 | + |
| 56 | +assert.throws(() => |
| 57 | + https.createServer({ |
| 58 | + key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`), |
| 59 | + cert: false |
| 60 | + }), /"options\.cert" must not be a boolean/); |
| 61 | + |
| 62 | +assert.throws(() => |
| 63 | + https.createServer({ |
| 64 | + key: false, |
| 65 | + cert: false |
| 66 | + }), /"options\.key" must not be a boolean/); |
| 67 | + |
| 68 | +assert.throws(() => |
| 69 | + https.createServer({ |
| 70 | + key: true, |
| 71 | + cert: true |
| 72 | + }), /"options\.key" must not be a boolean/); |
| 73 | + |
| 74 | +assert.throws(() => |
| 75 | + https.createServer({ |
| 76 | + key: true, |
| 77 | + cert: false |
| 78 | + }), /"options\.key" must not be a boolean/); |
| 79 | + |
| 80 | +assert.throws(() => |
| 81 | + https.createServer({ |
| 82 | + key: false, |
| 83 | + cert: true |
| 84 | + }), /"options\.key" must not be a boolean/); |
0 commit comments