forked from ddo/oauth-1.0a
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude default ports 80/443 from base URL
Fix ddo#59.
- Loading branch information
Showing
5 changed files
with
142 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var expect = require('chai').expect; | ||
var OAuth = require('../oauth-1.0a'); | ||
|
||
describe('#getBaseUrl', function() { | ||
var oauth = new OAuth({consumer: {}}); | ||
|
||
beforeEach(function () { | ||
oauth = new OAuth({consumer: {}}); | ||
}); | ||
|
||
it('should return base url', function () { | ||
expect(oauth.getBaseUrl('http://example.com/path/')).to.equal('http://example.com/path/'); | ||
expect(oauth.getBaseUrl('http://example.com/path/?foo=bar')).to.equal('http://example.com/path/'); | ||
}); | ||
|
||
it('should exclude default port number', function () { | ||
expect(oauth.getBaseUrl('http://example.com/')).to.equal('http://example.com/'); | ||
expect(oauth.getBaseUrl('http://example.com:80/')).to.equal('http://example.com/'); | ||
expect(oauth.getBaseUrl('https://example.com/')).to.equal('https://example.com/'); | ||
expect(oauth.getBaseUrl('https://example.com:443/')).to.equal('https://example.com/'); | ||
}); | ||
|
||
it('should include non-default port number', function () { | ||
expect(oauth.getBaseUrl('http://example.com:8080/')).to.equal('http://example.com:8080/'); | ||
expect(oauth.getBaseUrl('http://example.com:443/')).to.equal('http://example.com:443/'); | ||
expect(oauth.getBaseUrl('https://example.com:8080/')).to.equal('https://example.com:8080/'); | ||
expect(oauth.getBaseUrl('https://example.com:80/')).to.equal('https://example.com:80/'); | ||
}); | ||
}); |
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,46 @@ | ||
var expect = require('chai').expect; | ||
var OAuth = require('../oauth-1.0a'); | ||
|
||
describe('OAuth.parseUrl', function() { | ||
|
||
it('should parse protocol', function () { | ||
expect(OAuth.parseUrl('http://example.com/').protocol).to.equal('http'); | ||
expect(OAuth.parseUrl('https://example.com/').protocol).to.equal('https'); | ||
}); | ||
|
||
it('should parse auth component', function () { | ||
expect(OAuth.parseUrl('http://example.com/').auth).to.equal(''); | ||
expect(OAuth.parseUrl('http://foo:[email protected]/').auth).to.equal('foo:bar@'); | ||
}); | ||
|
||
it('should parse hostname component', function () { | ||
expect(OAuth.parseUrl('http://example.com/').hostname).to.equal('example.com'); | ||
expect(OAuth.parseUrl('http://example.com:8080/').hostname).to.equal('example.com'); | ||
expect(OAuth.parseUrl('http://foo:[email protected]/').hostname).to.equal('example.com'); | ||
}); | ||
|
||
it('should parse port component', function () { | ||
expect(OAuth.parseUrl('http://example.com/').port).to.equal(''); | ||
expect(OAuth.parseUrl('http://example.com:80/').port).to.equal(':80'); | ||
expect(OAuth.parseUrl('http://foo:[email protected]:80/').port).to.equal(':80'); | ||
}); | ||
|
||
it('should parse pathname component', function () { | ||
expect(OAuth.parseUrl('http://example.com').pathname).to.equal(''); | ||
expect(OAuth.parseUrl('http://example.com/').pathname).to.equal('/'); | ||
expect(OAuth.parseUrl('http://example.com/foo/bar').pathname).to.equal('/foo/bar'); | ||
}); | ||
|
||
it('should parse search component', function () { | ||
expect(OAuth.parseUrl('http://example.com').search).to.equal(''); | ||
expect(OAuth.parseUrl('http://example.com/?foo').search).to.equal('?foo'); | ||
expect(OAuth.parseUrl('http://example.com/?foo#bar').search).to.equal('?foo'); | ||
expect(OAuth.parseUrl('http://example.com/?foo?bar').search).to.equal('?foo?bar'); | ||
}); | ||
|
||
it('should parse hash component', function () { | ||
expect(OAuth.parseUrl('http://example.com').hash).to.equal(''); | ||
expect(OAuth.parseUrl('http://example.com/?foo').hash).to.equal(''); | ||
expect(OAuth.parseUrl('http://example.com/?foo#bar').hash).to.equal('#bar'); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -180,4 +180,4 @@ describe("Twitter Personal Consumer", function() { | |
}); | ||
}); | ||
}); | ||
}); | ||
}); |