This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from xemle/honor-npmrc-cafile-property-0.17
Honor npmrc cafile property 0.17
- Loading branch information
Showing
7 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
--reporter spec | ||
test/auth.spec.js | ||
test/npmrc.spec.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
var expect = require('unexpected') | ||
.clone() | ||
.use(require('unexpected-mitm')); | ||
var Npmrc = require('../lib/npmrc'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
|
||
function extend(a, b) { | ||
for (var p in b) | ||
a[p] = b[p]; | ||
return a; | ||
} | ||
|
||
function FileMock(path) { | ||
this.path = path; | ||
}; | ||
|
||
FileMock.prototype.write = function(content) { | ||
fs.writeFileSync(this.path, content); | ||
return this; | ||
}; | ||
|
||
FileMock.prototype.unlink = function() { | ||
fs.unlinkSync(this.path); | ||
}; | ||
|
||
describe('lib/npmrc', function () { | ||
|
||
describe('getCa()', function () { | ||
var _jspmConfigPath; | ||
var npmrc; | ||
|
||
beforeEach(function() { | ||
_jspmConfigPath = process.env.jspmConfigPath; | ||
npmrc = new Npmrc(); | ||
}); | ||
|
||
afterEach(function() { | ||
if (_jspmConfigPath) | ||
process.env.jspmConfigPath = _jspmConfigPath; | ||
}); | ||
|
||
it('should honor cafile property', function () { | ||
var npmrcFile; | ||
var caFile; | ||
var ca; | ||
|
||
delete process.env.jspmConfigPath; | ||
caFile = new FileMock(path.resolve(process.cwd(), 'ca.crt')) | ||
.write('ca certificate'); | ||
npmrcFile = new FileMock(path.resolve(process.cwd(), '.npmrc')) | ||
.write('cafile=' + caFile.path); | ||
|
||
|
||
var ca = npmrc.getCa(); | ||
|
||
|
||
caFile.unlink(); | ||
npmrcFile.unlink(); | ||
return expect(ca, 'when decoded as', 'utf-8', 'to equal', 'ca certificate'); | ||
}); | ||
|
||
it('should have empty ca', function () { | ||
var npmrcFile; | ||
var ca; | ||
|
||
delete process.env.jspmConfigPath; | ||
npmrcFile = new FileMock(path.resolve(process.cwd(), '.npmrc')) | ||
.write('# empty config'); | ||
|
||
|
||
var ca = npmrc.getCa(); | ||
|
||
|
||
npmrcFile.unlink(); | ||
return expect(ca, 'to be undefined'); | ||
}); | ||
}); | ||
}); |