diff --git a/lib/gofer.js b/lib/gofer.js index f8ba71e..5e64c59 100644 --- a/lib/gofer.js +++ b/lib/gofer.js @@ -96,7 +96,7 @@ function preventComplexMerge(objValue, srcValue) { return srcValue || objValue; } - return mergeWith(objValue, srcValue, preventComplexMerge); + return mergeWith({}, objValue, srcValue, preventComplexMerge); } Gofer.prototype._prepareOptions = diff --git a/package.json b/package.json index 6b5153b..f7bb741 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "mochify": "^2.17.0", "nlm": "^3.0.0", "promise": "^7.1.1", + "self-signed": "^1.3.1", "whatwg-fetch": "^0.11.0" }, "author": { diff --git a/test/certs/ca/my-root-ca.crt.pem b/test/certs/ca/my-root-ca.crt.pem deleted file mode 100644 index 4bd1af8..0000000 --- a/test/certs/ca/my-root-ca.crt.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDoTCCAomgAwIBAgIJAL83lAMyAi5sMA0GCSqGSIb3DQEBCwUAMGcxCzAJBgNV -BAYTAlVTMQ0wCwYDVQQIDARVdGFoMQ4wDAYDVQQHDAVQcm92bzEjMCEGA1UECgwa -QUNNRSBTaWduaW5nIEF1dGhvcml0eSBJbmMxFDASBgNVBAMMC2V4YW1wbGUuY29t -MB4XDTE2MDQxODIwMDU1N1oXDTE5MDIwNjIwMDU1N1owZzELMAkGA1UEBhMCVVMx -DTALBgNVBAgMBFV0YWgxDjAMBgNVBAcMBVByb3ZvMSMwIQYDVQQKDBpBQ01FIFNp -Z25pbmcgQXV0aG9yaXR5IEluYzEUMBIGA1UEAwwLZXhhbXBsZS5jb20wggEiMA0G -CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCiMISu6F/nsIltkJOiBlSe+sdVLF2i -6yGC+z592gTkJdsrN5RrBHWuU6j5FQfQ2ZrcRQwr/lc2bo76so/pcZozvaQ5CfYM -RT8vv9xOV/K+TS1XMVQ57gF5fpDKvhEtvu9E29Q8eNFWcaIlnPsN76esLasUYM7Q -6vFjptTtQ1hKRhxPC3G36OdiM2uGnpRy5+n6X6nZD6S/gzY4DBO2YVlZG9fRb5XJ -w+HZc3mWACsM8rbalFCTBddXUWSK0Xr8yHz3ug9qhiCv41APve7ZtHUF4yPAMnnL -hEg+m+UQZHYx7B01JEDWhtTQ3dUo2DxWVZHUMlXDNuGejU0qtF2Au0p9AgMBAAGj -UDBOMB0GA1UdDgQWBBRQmRC2Pv5oOGdsGXyzPOKOFGcAnDAfBgNVHSMEGDAWgBRQ -mRC2Pv5oOGdsGXyzPOKOFGcAnDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA -A4IBAQCRRhbdwHReQ9pcAE76ZDhWeGM47R4erP77gLS8PCtySOmMYtfP1gvHlHrQ -uv7PbEJtCtCN1v2Obh70K43LyMkzU4yfAArbJILMLGl+GzRX0Qq3S4JF7lx0OouO -NFjTCgA0RygLI83gszQiK5TPbq90flT/auv9QUJWkrFWmC4YIkI3Ghwi8n1RXHGl -/EMz6DDwtjQbY5/lRaOTs0NB5RePo5Dy34oqtCn+sufeqdDwAK8GJZBTmlpG8uc8 -6//Pp6knJuzR2xWizjkjJM5VG4lv9UVU6jsdr4dnwfxCjX/dpEqTL9rR+OZM5r3T -xyof9OlZb0Dho7wxI0Hi4InzU9Jy ------END CERTIFICATE----- diff --git a/test/certs/ca/my-root-ca.key.pem b/test/certs/ca/my-root-ca.key.pem deleted file mode 100644 index 4c07bda..0000000 --- a/test/certs/ca/my-root-ca.key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAojCEruhf57CJbZCTogZUnvrHVSxdoushgvs+fdoE5CXbKzeU -awR1rlOo+RUH0Nma3EUMK/5XNm6O+rKP6XGaM72kOQn2DEU/L7/cTlfyvk0tVzFU -Oe4BeX6Qyr4RLb7vRNvUPHjRVnGiJZz7De+nrC2rFGDO0OrxY6bU7UNYSkYcTwtx -t+jnYjNrhp6Ucufp+l+p2Q+kv4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kf8xQ5J -za4ZxWMEA05NfZL9eTG0U8otUpB3tTquArGIuBRElIutHatx5bga4YkPPdFXng3A -BBiYkw3Fie4ilnppNSxQZhy8Lw+qPF/uyHFRmCI4NBthxjlu5i2fJ6bOAvBzGP0O -ZDnoUQKBgBYzoOwTDpjwx9etTGeNfa3ImZDliEEvkawdZgCsgzufgwbz9T+rxr9n -+YZUcKjZlFOoGMg8dWcqiRZqUesraH9toNDryRV8eBJVgmoH5+PS5Or8uwsi1iqP -nPyOk5wqClT0roZoNHWOhTqL5t2Eu1aUmhTXEI0iBiBm80TlUeYD ------END RSA PRIVATE KEY----- diff --git a/test/certs/ca/my-root-ca.srl b/test/certs/ca/my-root-ca.srl deleted file mode 100644 index bf9b942..0000000 --- a/test/certs/ca/my-root-ca.srl +++ /dev/null @@ -1 +0,0 @@ -E2F57A08825F5D53 diff --git a/test/certs/client/my-root-ca.crt.pem b/test/certs/client/my-root-ca.crt.pem deleted file mode 100644 index 4bd1af8..0000000 --- a/test/certs/client/my-root-ca.crt.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDoTCCAomgAwIBAgIJAL83lAMyAi5sMA0GCSqGSIb3DQEBCwUAMGcxCzAJBgNV -BAYTAlVTMQ0wCwYDVQQIDARVdGFoMQ4wDAYDVQQHDAVQcm92bzEjMCEGA1UECgwa -QUNNRSBTaWduaW5nIEF1dGhvcml0eSBJbmMxFDASBgNVBAMMC2V4YW1wbGUuY29t -MB4XDTE2MDQxODIwMDU1N1oXDTE5MDIwNjIwMDU1N1owZzELMAkGA1UEBhMCVVMx -DTALBgNVBAgMBFV0YWgxDjAMBgNVBAcMBVByb3ZvMSMwIQYDVQQKDBpBQ01FIFNp -Z25pbmcgQXV0aG9yaXR5IEluYzEUMBIGA1UEAwwLZXhhbXBsZS5jb20wggEiMA0G -CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCiMISu6F/nsIltkJOiBlSe+sdVLF2i -6yGC+z592gTkJdsrN5RrBHWuU6j5FQfQ2ZrcRQwr/lc2bo76so/pcZozvaQ5CfYM -RT8vv9xOV/K+TS1XMVQ57gF5fpDKvhEtvu9E29Q8eNFWcaIlnPsN76esLasUYM7Q -6vFjptTtQ1hKRhxPC3G36OdiM2uGnpRy5+n6X6nZD6S/gzY4DBO2YVlZG9fRb5XJ -w+HZc3mWACsM8rbalFCTBddXUWSK0Xr8yHz3ug9qhiCv41APve7ZtHUF4yPAMnnL -hEg+m+UQZHYx7B01JEDWhtTQ3dUo2DxWVZHUMlXDNuGejU0qtF2Au0p9AgMBAAGj -UDBOMB0GA1UdDgQWBBRQmRC2Pv5oOGdsGXyzPOKOFGcAnDAfBgNVHSMEGDAWgBRQ -mRC2Pv5oOGdsGXyzPOKOFGcAnDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA -A4IBAQCRRhbdwHReQ9pcAE76ZDhWeGM47R4erP77gLS8PCtySOmMYtfP1gvHlHrQ -uv7PbEJtCtCN1v2Obh70K43LyMkzU4yfAArbJILMLGl+GzRX0Qq3S4JF7lx0OouO -NFjTCgA0RygLI83gszQiK5TPbq90flT/auv9QUJWkrFWmC4YIkI3Ghwi8n1RXHGl -/EMz6DDwtjQbY5/lRaOTs0NB5RePo5Dy34oqtCn+sufeqdDwAK8GJZBTmlpG8uc8 -6//Pp6knJuzR2xWizjkjJM5VG4lv9UVU6jsdr4dnwfxCjX/dpEqTL9rR+OZM5r3T -xyof9OlZb0Dho7wxI0Hi4InzU9Jy ------END CERTIFICATE----- diff --git a/test/certs/client/my-server.pub b/test/certs/client/my-server.pub deleted file mode 100644 index e53d5e3..0000000 --- a/test/certs/client/my-server.pub +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2F5MV1j7lMAc1oKKqFJ7 -+1tzXbI6bPZKahIEcmTFFwvMUekjKSOtbtsMaevGXJxQReZkZTsGOeSrHba6RCc0 -C0V7JHLNiFTuIECkKlesH9rSRT6b8sxQkSsZugL6f0ypyc5H4buz5wN5FLN/PEqu -txNxU/kC5XAkdFpjLAUNCGa13/F4w66wTPBpWcqWbYJ1RmjnP7+lFRWuU1VoBi23 -lDZv8frfrNzRdDAB7XUNL7O9Zfx3mgC2jQ0P2NP27gYh+a3vJHWX9PcGWJ2RWG5P -H9Gln+vm9lRaLJOOvijm/q447NA9luiEy2w2JfsFFiN+VVGH5Moq5XGuf68qbIrL -1wIDAQAB ------END PUBLIC KEY----- diff --git a/test/certs/server/my-root-ca.crt.pem b/test/certs/server/my-root-ca.crt.pem deleted file mode 100644 index 4bd1af8..0000000 --- a/test/certs/server/my-root-ca.crt.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDoTCCAomgAwIBAgIJAL83lAMyAi5sMA0GCSqGSIb3DQEBCwUAMGcxCzAJBgNV -BAYTAlVTMQ0wCwYDVQQIDARVdGFoMQ4wDAYDVQQHDAVQcm92bzEjMCEGA1UECgwa -QUNNRSBTaWduaW5nIEF1dGhvcml0eSBJbmMxFDASBgNVBAMMC2V4YW1wbGUuY29t -MB4XDTE2MDQxODIwMDU1N1oXDTE5MDIwNjIwMDU1N1owZzELMAkGA1UEBhMCVVMx -DTALBgNVBAgMBFV0YWgxDjAMBgNVBAcMBVByb3ZvMSMwIQYDVQQKDBpBQ01FIFNp -Z25pbmcgQXV0aG9yaXR5IEluYzEUMBIGA1UEAwwLZXhhbXBsZS5jb20wggEiMA0G -CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCiMISu6F/nsIltkJOiBlSe+sdVLF2i -6yGC+z592gTkJdsrN5RrBHWuU6j5FQfQ2ZrcRQwr/lc2bo76so/pcZozvaQ5CfYM -RT8vv9xOV/K+TS1XMVQ57gF5fpDKvhEtvu9E29Q8eNFWcaIlnPsN76esLasUYM7Q -6vFjptTtQ1hKRhxPC3G36OdiM2uGnpRy5+n6X6nZD6S/gzY4DBO2YVlZG9fRb5XJ -w+HZc3mWACsM8rbalFCTBddXUWSK0Xr8yHz3ug9qhiCv41APve7ZtHUF4yPAMnnL -hEg+m+UQZHYx7B01JEDWhtTQ3dUo2DxWVZHUMlXDNuGejU0qtF2Au0p9AgMBAAGj -UDBOMB0GA1UdDgQWBBRQmRC2Pv5oOGdsGXyzPOKOFGcAnDAfBgNVHSMEGDAWgBRQ -mRC2Pv5oOGdsGXyzPOKOFGcAnDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUA -A4IBAQCRRhbdwHReQ9pcAE76ZDhWeGM47R4erP77gLS8PCtySOmMYtfP1gvHlHrQ -uv7PbEJtCtCN1v2Obh70K43LyMkzU4yfAArbJILMLGl+GzRX0Qq3S4JF7lx0OouO -NFjTCgA0RygLI83gszQiK5TPbq90flT/auv9QUJWkrFWmC4YIkI3Ghwi8n1RXHGl -/EMz6DDwtjQbY5/lRaOTs0NB5RePo5Dy34oqtCn+sufeqdDwAK8GJZBTmlpG8uc8 -6//Pp6knJuzR2xWizjkjJM5VG4lv9UVU6jsdr4dnwfxCjX/dpEqTL9rR+OZM5r3T -xyof9OlZb0Dho7wxI0Hi4InzU9Jy ------END CERTIFICATE----- diff --git a/test/certs/server/my-server.crt.pem b/test/certs/server/my-server.crt.pem deleted file mode 100644 index 1adcdfe..0000000 --- a/test/certs/server/my-server.crt.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDOzCCAiMCCQDi9XoIgl9dUzANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJV -UzENMAsGA1UECAwEVXRhaDEOMAwGA1UEBwwFUHJvdm8xIzAhBgNVBAoMGkFDTUUg -U2lnbmluZyBBdXRob3JpdHkgSW5jMRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0x -NjA0MTgyMDA1NTdaFw0xNzA4MzEyMDA1NTdaMFgxCzAJBgNVBAYTAlVTMQ0wCwYD -VQQIDARVdGFoMQ4wDAYDVQQHDAVQcm92bzEWMBQGA1UECgwNQUNNRSBUZWNoIElu -YzESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEA2F5MV1j7lMAc1oKKqFJ7+1tzXbI6bPZKahIEcmTFFwvMUekjKSOtbtsM -aevGXJxQReZkZTsGOeSrHba6RCc0C0V7JHLNiFTuIECkKlesH9rSRT6b8sxQkSsZ -ugL6f0ypyc5H4buz5wN5FLN/PEqutxNxU/kC5XAkdFpjLAUNCGa13/F4w66wTPBp -WcqWbYJ1RmjnP7+lFRWuU1VoBi23lDZv8frfrNzRdDAB7XUNL7O9Zfx3mgC2jQ0P -2NP27gYh+a3vJHWX9PcGWJ2RWG5PH9Gln+vm9lRaLJOOvijm/q447NA9luiEy2w2 -JfsFFiN+VVGH5Moq5XGuf68qbIrL1wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBn -ISho93Z3IXLDB+wTZXd4dco1zfTRXzpM999SA8pVPRPytPOSYhg1435qmJsqrNZb -m3I+Fh+uZofYXkAynuhtyJMH31DYJ3QdmpozG3yK26PTCONVVG6i4iGKp7HptRb2 -X6fSRv8HDx2JMAljxv6wWqMA4dCoEXXhtPum98QDNjqcLO/hOeVkUTaP/ACreZAz -N9IlOZJ02gHzLD2H2HYbcBnzwiIwaLoizgWUmPbGKaj2MoOte4xXej+6kNxPwhtF -f+nQmCkikLctuLI+iAybkILeUqPqCMjkC9yE6pLMhOaK/bheso/+jcvatef0bW3H -C3ASAvrWoBZiir66U/Ht ------END CERTIFICATE----- diff --git a/test/certs/server/my-server.key.pem b/test/certs/server/my-server.key.pem deleted file mode 100644 index bfe965b..0000000 --- a/test/certs/server/my-server.key.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEA2F5MV1j7lMAc1oKKqFJ7+1tzXbI6bPZKahIEcmTFFwvMUekj -KSOtbtsMaevGXJxQReZkZTsGOeS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qdHnX74kJM2iv+AIQWcrp/Y -awPu7+9j5ga3+nr51O8kCc7Imj+nwciexSur59LUtFAbVcLK4H/ek0x7OdrJUWDb -mF8rYNLznsu8CRRd3Zb/cwKBgD4Gg5n46q7N8lXaV5F74SThrVPcxdSTZY5ukaN1 -3Nm1voLhXtlrEwdZx6X7Wx6htOpUYlNfQgiZ2++hbSb1Ga9aoucCBSCuNd34DuFy -fc+HZwX42/chjV+4TNdWbTglQlw8JZaX5imWUY4X/fHqKzhYHMWCspcPFDnLb0Lp -zlWdAoGBAMvcRpwAf0SEnDK6smEsfwzTjp8JuIktT284S7/Hpzpq2pNLjQ93GLuy -ol37VfPQW735ITQ1NP5IbBrabZBxB0pZWS/e4YqGr82j3O8NAapYvRaNIotQAGmi -zj+jDATp3x30cYQOMpcUr/tvW4V6ECzsA/oQQ9YlqIssnaaaJi/M ------END RSA PRIVATE KEY----- diff --git a/test/certs/tmp/my-server.csr.pem b/test/certs/tmp/my-server.csr.pem deleted file mode 100644 index 163f8d1..0000000 --- a/test/certs/tmp/my-server.csr.pem +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIICnTCCAYUCAQAwWDELMAkGA1UEBhMCVVMxDTALBgNVBAgMBFV0YWgxDjAMBgNV -BAcMBVByb3ZvMRYwFAYDVQQKDA1BQ01FIFRlY2ggSW5jMRIwEAYDVQQDDAlsb2Nh -bGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDYXkxXWPuUwBzW -goqoUnv7W3Ndsjps9kpqEgRyZMUXC8xR6SMpI61u2wxp68ZcnFBF5mRlOwY55Ksd -trpEJzQLRXskcs2IVO4gQKQqV6wf2tJFPpvyzFCRKxm6Avp/TKnJzkfhu7PnA3kU -s388Sq63E3FT+QLlcCR0WmMsBQ0IZrXf8XjDrrBM8GlZypZtgnVGaOc/v6UVFa5T -VWgGLbeUNm/x+t+s3NF0MAHtdQ0vs71l/HeaALaNDQ/Y0/buBiH5re8kdZf09wZY -nZFYbk8f0aWf6+b2VFosk46+KOb+rjjs0D2W6ITLbDYl+wUWI35VUYfkyirlca5/ -rypsisvXAgMBAAGgADANBgkqhkiG9w0BAQsFAAOCAQEArvKtcUOfm6cMTDIZhmqC -5N86Jaz7OkedDEmhZf6JTbhZx7n4P/13IlWDICyOIZLVw6oW/CJ8cVsw+K5J2BtK -D0cs0caiCeki01ML3i9EeunVlNKvPIJ9mOla0YIV1gH3vylldGwMlpa3ZsBR8Si2 -shbJ4r6D6dosY9pKhQ4Ifd1krIKVQLWhWuCpyP+LfTmlsZRbzx+HiE85MmwjqbHt -YgYrMB+DVVQEjkRXjDGoAUNIE/hoN2BZGD3C50JBOl+5mNTSLHA2BJm6503AgUE6 -ZprMfEjgpHCrJpZBfqoy2GK6PwykbG8XemqLID9IzGJ3nrHGpt4QmdrakxWoSfEI -AA== ------END CERTIFICATE REQUEST----- diff --git a/test/fetch-https.test.js b/test/fetch-https.test.js index 853d0b1..cfc190b 100644 --- a/test/fetch-https.test.js +++ b/test/fetch-https.test.js @@ -15,10 +15,8 @@ describe('fetch: https', function () { // This is a remote call which isn't great but it means we get a valid // https certificate without having to pull any tricks. this.timeout(2000); - return fetch('https://api.reddit.com/r/javascript/about.json') - .then(function (res) { - assert.equal(200, res.statusCode); - }); + return fetch('https://api.reddit.com/user/ageitgey/about.json') + .json(); }); it('fails with self-signed https', function () { @@ -28,10 +26,10 @@ describe('fetch: https', function () { if (typeof document === 'undefined') { if (error.code) { // more recent node versions (e.g. 4+) - assert.equal('SELF_SIGNED_CERT_IN_CHAIN', error.code); + assert.match(/SELF_SIGNED/, error.code); } else { // old node versions (e.g. 0.10) - assert.equal('SELF_SIGNED_CERT_IN_CHAIN', error.message); + assert.match(/SELF_SIGNED/, error.message); } } }); @@ -55,9 +53,8 @@ describe('fetch: https', function () { // Browsers don't allow to side-step https return this.skip(); } - var fs = require('fs'); return fetch(options.baseUrlTls, { - ca: fs.readFileSync('test/certs/client/my-root-ca.crt.pem'), + ca: [options.certOptions.cert], }) .then(function (res) { assert.equal(200, res.statusCode); diff --git a/test/gofer.test.js b/test/gofer.test.js index 5780485..d7531ab 100644 --- a/test/gofer.test.js +++ b/test/gofer.test.js @@ -25,6 +25,27 @@ describe('gofer', function () { }); }); + describe('call that sets a header', function () { + var gofer; + before(function () { + gofer = new Gofer().with({ + headers: { 'x-a': 'foo' }, + }).with(options); + + return gofer.fetch('/echo', { + headers: { 'x-b': 'should not leak' }, + }).json(); + }); + + it('does not affect defaults', function () { + return gofer.fetch('/echo').json() + .then(function (echo) { + assert.equal('foo', echo.headers['x-a']); + assert.equal(undefined, echo.headers['x-b']); + }); + }); + }); + describe('sub-class', function () { function SubGofer(config) { Gofer.call(this, config, 'sub', '1.2.3', 'my-sub-client'); diff --git a/test/mock-service.js b/test/mock-service.js index c1d524f..0491c87 100644 --- a/test/mock-service.js +++ b/test/mock-service.js @@ -1,9 +1,11 @@ 'use strict'; -var fs = require('fs'); + var http = require('http'); var https = require('https'); var parseUrl = require('url').parse; +var selfSigned = require('self-signed'); + var options = require('./mock-service.browser'); var MOCK_SERVICE_PORT = +(options.baseUrl.match(/:(\d+)/)[1]); @@ -12,6 +14,24 @@ var MOCK_SERVICE_PORT_TLS = +(options.baseUrlTls.match(/:(\d+)/)[1]); var server; var serverTls; +function generateCertOptions() { + var keypair = selfSigned({ + name: 'localhost', + city: 'Chicago', + state: 'Illinois', + organization: 'Test', + unit: 'Test', + }, { + alt: ['127.0.0.1', 'http://localhost'], + expire: 60 * 60 * 1000, // one hour + }); + return { + cert: keypair.cert, + key: keypair.private, + }; +} +var certOptions = generateCertOptions(); + function sendEcho(req, res) { var chunks = []; var query = parseUrl(req.url, true).query; @@ -96,7 +116,7 @@ function handleRequest(req, res) { res.setHeader('Access-Control-Allow-Origin', req.headers.origin); } res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, HEAD, OPTIONS, DELETE, PATCH'); - res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); + res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, x-a, x-b'); // Preflight requests that return a 404 confuse Chrome if (req.method === 'OPTIONS') return res.end(); @@ -123,15 +143,10 @@ function bootupServers(done) { } server = http.createServer(handleRequest); server.on('error', done); - server.listen(MOCK_SERVICE_PORT, onListen); - var certOptions = { - key: fs.readFileSync('test/certs/server/my-server.key.pem'), - ca: [fs.readFileSync('test/certs/server/my-root-ca.crt.pem')], - cert: fs.readFileSync('test/certs/server/my-server.crt.pem'), - }; + server.listen(MOCK_SERVICE_PORT, '127.0.0.1', onListen); serverTls = https.createServer(certOptions, handleRequest); serverTls.on('error', done); - serverTls.listen(MOCK_SERVICE_PORT_TLS, onListen); + serverTls.listen(MOCK_SERVICE_PORT_TLS, '127.0.0.1', onListen); } if (typeof before === 'function') { @@ -163,4 +178,6 @@ if (process.mainModule === module) { }); } +// Exposed for the https test so we can set up a compatible client +options.certOptions = certOptions; module.exports = options;