Skip to content
This repository has been archived by the owner on Apr 21, 2020. It is now read-only.

Commit

Permalink
Run all outbound tests over both http and https.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbreen committed Mar 17, 2015
1 parent 8345599 commit b421d76
Showing 1 changed file with 33 additions and 37 deletions.
70 changes: 33 additions & 37 deletions test/oauth_proxy_outbound_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Test that requests sent through an outbound proxy are properly signed.
*/
var sprintf = require('../lib/sprintf.js').sprintf;

// All the messy business of creating and sending requests (both authenticated and unauthenticated)
// lives in request_sender.
Expand All @@ -14,43 +15,38 @@ require('./auth_proxy_bootstrap_test.js');
// Tests that verbs are handled correctly by oauth_reverse_proxy
describe('oauth_proxy outbound message integrity: verbs', function() {

// GETs and DELETEs have the same URL format and do not expect input, so test them both in a loop.
['GET', 'DELETE'].forEach(function(verb) {

// Validate that a basic GET or DELETE request works when signed using an oauth_proxy.
it ("should accept a properly signed basic " + verb + " request", function(done) {
request_sender.sendRequest(verb, 'http://localhost:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent('http://localhost:8008/job/12345'),
null, 200, done);
});

// Validate that a basic GET or DELETE over IPv6 works.
it ("should accept a properly signed " + verb + " over IPv6", function(done) {
request_sender.sendRequest(verb, 'http://[::1]:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent('http://[::1]:8008/job/12345'),
null, 200, done);
});

// Validate that a GET or DELETE with query parameters works.
it ("should accept a properly signed " + verb + " with query", function(done) {
request_sender.sendRequest(verb, 'http://localhost:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent('http://localhost:8008/job/12345?query=ok'),
null, 200, done);
});

// Validate that a GET or DELETE over IPv6 with query parameters works.
it ("should accept a properly signed " + verb + " over IPv6 with query", function(done) {
request_sender.sendRequest(verb, 'http://[::1]:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent('http://[::1]:8008/job/12345?query=ok'),
null, 200, done);
});


// Validate that a basic GET or DELETE request works when signed using an oauth_proxy.
it ("should accept a properly signed basic " + verb + " request", function(done) {
request_sender.sendRequest(verb, 'http://localhost:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent('https://localhost:8443/job/12345'),
null, 200, done);
["http", "https"].forEach(function(proto) {

// GETs and DELETEs have the same URL format and do not expect input, so test them both in a loop.
['GET', 'DELETE'].forEach(function(verb) {

// Validate that a basic GET or DELETE request works when signed using an oauth_proxy.
it ("should accept a properly signed basic " + verb + " request via " + proto, function(done) {
request_sender.sendRequest(verb, 'http://localhost:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent(sprintf('%s://localhost:%s/job/12345', proto, (proto === 'http' ? '8008' : '8443'))),
null, 200, done);
});

// Validate that a basic GET or DELETE over IPv6 works.
it ("should accept a properly signed " + verb + " over IPv6 via " + proto, function(done) {
request_sender.sendRequest(verb, 'http://[::1]:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent(sprintf('%s://[::1]:%s/job/12345', proto, (proto === 'http' ? '8008' : '8443'))),
null, 200, done);
});

// Validate that a GET or DELETE with query parameters works.
it ("should accept a properly signed " + verb + " with query via " + proto, function(done) {
request_sender.sendRequest(verb, 'http://localhost:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent(sprintf('%s://localhost:%s/job/12345?query=ok', proto, (proto === 'http' ? '8008' : '8443'))),
null, 200, done);
});

// Validate that a GET or DELETE over IPv6 with query parameters works.
it ("should accept a properly signed " + verb + " over IPv6 with query via " + proto, function(done) {
request_sender.sendRequest(verb, 'http://[::1]:8282/?oauth_proxy_consumer_key=mocha-test-key&oauth_proxy_url=' +
encodeURIComponent(sprintf('%s://[::1]:%s/job/12345?query=ok', proto, (proto === 'http' ? '8008' : '8443'))),
null, 200, done);
});
});
});

Expand Down

0 comments on commit b421d76

Please sign in to comment.