bower-registry-client
Advanced tools
Comparing version 0.1.6 to 0.2.0
@@ -24,2 +24,3 @@ var async = require('async'); | ||
RegistryClient.prototype.register = methods.register; | ||
RegistryClient.prototype.unregister = methods.unregister; | ||
@@ -26,0 +27,0 @@ RegistryClient.prototype.clearCache = function (name, callback) { |
@@ -5,3 +5,4 @@ module.exports = { | ||
register: require('./register'), | ||
search: require('./search') | ||
search: require('./search'), | ||
unregister: require('./unregister') | ||
}; |
@@ -99,3 +99,3 @@ var path = require('path'); | ||
ca: this._config.ca.search[index], | ||
headers:headers, | ||
headers: headers, | ||
strictSSL: this._config.strictSsl, | ||
@@ -102,0 +102,0 @@ timeout: this._config.timeout, |
@@ -90,3 +90,3 @@ var path = require('path'); | ||
proxy: remote.protocol === 'https:' ? this._config.httpsProxy : this._config.proxy, | ||
headers:headers, | ||
headers: headers, | ||
ca: this._config.ca.search[index], | ||
@@ -118,6 +118,10 @@ strictSSL: this._config.strictSsl, | ||
callback(null, { | ||
type: 'alias', | ||
url: body.url | ||
}); | ||
var data; | ||
if (body.url) { | ||
data = { | ||
type: 'alias', | ||
url: body.url | ||
}; | ||
} | ||
callback(null, data); | ||
})); | ||
@@ -124,0 +128,0 @@ |
@@ -15,6 +15,10 @@ var parseUrl = require('url').parse; | ||
if (config.accessToken) { | ||
requestUrl += '?access_token=' + config.accessToken; | ||
} | ||
request.post({ | ||
url: requestUrl, | ||
proxy: remote.protocol === 'https:' ? config.httpsProxy : config.proxy, | ||
headers:headers, | ||
headers: headers, | ||
ca: config.ca.register, | ||
@@ -21,0 +25,0 @@ strictSSL: config.strictSsl, |
@@ -106,3 +106,3 @@ var path = require('path'); | ||
proxy: remote.protocol === 'https:' ? this._config.httpsProxy : this._config.proxy, | ||
headers:headers, | ||
headers: headers, | ||
ca: this._config.ca.search[index], | ||
@@ -109,0 +109,0 @@ strictSSL: this._config.strictSsl, |
{ | ||
"name": "bower-registry-client", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Provides easy interaction with the Bower registry.", | ||
@@ -5,0 +5,0 @@ "author": "Twitter", |
@@ -198,2 +198,61 @@ var RegistryClient = require('../Client'); | ||
describe('calling the lookup instance method without argument', function () { | ||
it('should return no result', function (next) { | ||
this.registry.lookup('', function (err, entry) { | ||
expect(err).to.not.be.ok(); | ||
expect(entry).to.not.be.ok(); | ||
next(); | ||
}); | ||
}); | ||
}); | ||
describe('calling the lookup instance method with two registries, and the first missing.', function () { | ||
beforeEach(function () { | ||
nock('http://custom-registry.com') | ||
.get('/packages/jquery') | ||
.reply(200, { | ||
'error': { | ||
'message': 'missing', | ||
'stack': 'Error: missing' | ||
} | ||
}); | ||
nock('http://custom-registry2.com') | ||
.get('/packages/jquery') | ||
.reply(200, { | ||
name: 'jquery', | ||
url: 'git://github.com/foo/baz' | ||
}); | ||
this.registry = new RegistryClient({ | ||
strictSsl: false, | ||
force: true, | ||
registry: { | ||
search: [ | ||
'http://custom-registry.com', | ||
'http://custom-registry2.com' | ||
] | ||
} | ||
}); | ||
}); | ||
it('should return entry type', function (next) { | ||
this.registry.lookup('jquery', function (err, entry) { | ||
expect(err).to.be(null); | ||
expect(entry).to.be.an('object'); | ||
expect(entry.type).to.eql('alias'); | ||
next(); | ||
}); | ||
}); | ||
it('should return entry url ', function (next) { | ||
this.registry.lookup('jquery', function (err, entry) { | ||
expect(err).to.be(null); | ||
expect(entry).to.be.an('object'); | ||
expect(entry.url).to.eql('git://github.com/foo/baz'); | ||
next(); | ||
}); | ||
}); | ||
}); | ||
describe('calling the lookup instance method with three registries', function () { | ||
@@ -266,12 +325,2 @@ beforeEach(function () { | ||
describe('calling the lookup instance method without argument', function () { | ||
it('should return no result', function (next) { | ||
this.registry.lookup('', function (err, entry) { | ||
expect(err).to.not.be.ok(); | ||
expect(entry).to.not.be.ok(); | ||
next(); | ||
}); | ||
}); | ||
}); | ||
// | ||
@@ -336,2 +385,73 @@ // register | ||
// | ||
// unregister | ||
// | ||
describe('calling the unregister instance method with argument', function () { | ||
beforeEach(function () { | ||
this.pkg = 'testfoo'; | ||
this.accessToken = '12345678'; | ||
this.registry._config.accessToken = this.accessToken; | ||
nock('https://bower.herokuapp.com:443') | ||
.delete('/packages/' + this.pkg + '?access_token=' + this.accessToken) | ||
.reply(204); | ||
}); | ||
it('should not return an error when valid', function (next) { | ||
this.registry.unregister(this.pkg, function (err) { | ||
expect(err).to.be(null); | ||
next(); | ||
}); | ||
}); | ||
it('should return entry name', function (next) { | ||
var self = this; | ||
this.registry.unregister(this.pkg, function (err, entry) { | ||
expect(err).to.be(null); | ||
expect(entry.name).to.eql(self.pkg); | ||
next(); | ||
}); | ||
}); | ||
}); | ||
describe('calling the unregister instance method with invalid token', function () { | ||
beforeEach(function () { | ||
this.pkg = 'testfoo'; | ||
this.registry._config.accessToken = ''; | ||
nock('https://bower.herokuapp.com:443') | ||
.delete('/packages/' + this.pkg) | ||
.reply(403); | ||
}); | ||
it('should return an error', function (next) { | ||
this.registry.unregister(this.pkg, function (err, entry) { | ||
expect(err).to.be.an(Error); | ||
expect(entry).to.be(undefined); | ||
next(); | ||
}); | ||
}); | ||
}); | ||
describe('calling the unregister instance method with invalid package', function () { | ||
beforeEach(function () { | ||
this.notpkg = 'testbar'; | ||
this.accessToken = '12345678'; | ||
this.registry._config.accessToken = this.accessToken; | ||
nock('https://bower.herokuapp.com:443') | ||
.delete('/packages/' + this.notpkg + '?access_token=' + this.accessToken) | ||
.reply(404); | ||
}); | ||
it('should return an error', function (next) { | ||
this.registry.unregister(this.notpkg, function (err, entry) { | ||
expect(err).to.be.an(Error); | ||
expect(entry).to.be(undefined); | ||
next(); | ||
}); | ||
}); | ||
}); | ||
// | ||
// search | ||
@@ -592,5 +712,5 @@ // | ||
// | ||
describe('add a custom userAgent with argument',function(){ | ||
describe('add a custom userAgent with argument', function () { | ||
this.timeout(5000); | ||
it('should send custom userAgent to the server',function(next){ | ||
it('should send custom userAgent to the server', function (next) { | ||
var self = this; | ||
@@ -600,4 +720,4 @@ this.ua = ''; | ||
self.ua = req.headers['user-agent']; | ||
res.writeHeader(200,{ | ||
'Content-Type':'application/json' | ||
res.writeHeader(200, { | ||
'Content-Type': 'application/json' | ||
}); | ||
@@ -609,6 +729,6 @@ res.end('{"name":"jquery","url":"git://github.com/components/jquery.git"}'); | ||
this.registry = new RegistryClient({ | ||
userAgent:'test agent', | ||
registry:'http://127.0.0.1:7777' | ||
userAgent: 'test agent', | ||
registry: 'http://127.0.0.1:7777' | ||
}); | ||
this.registry.search('jquery', function (err,result) { | ||
this.registry.search('jquery', function (err, result) { | ||
expect(self.ua).to.be('test agent'); | ||
@@ -615,0 +735,0 @@ next(); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
95057
28
1738