Skip to content

Commit

Permalink
Remove remaining 0.10 related bits.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjeffburke committed Apr 27, 2018
1 parent e7f7522 commit ade9c21
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 395 deletions.
11 changes: 0 additions & 11 deletions lib/UnexpectedMitmMocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ var trimHeadersLower = require('./trimHeadersLower');

var expect = unexpected.clone().use(unexpectedMessy);

var isNodeZeroTen = !!process.version.match(/v0.10/);

function calculateBodyByteCount(chunk) {
var trailerIdx = findHeaderSeparator(chunk);
if (trailerIdx !== -1) {
Expand Down Expand Up @@ -306,15 +304,6 @@ UnexpectedMitmMocker.prototype.mock = function mock(consumptionFunction) {
this.push(result.body.shift() || null);
};

if (isNodeZeroTen) {
/*
* As is mentioned in the streams documentation this
* call can be issued to kick some of the machinery
* and is apparently done within the standard lib.
*/
req.read(0);
}

// call response function inside a promise to catch exceptions
return Promise.resolve().then(function () {
responseProperties(req, res);
Expand Down
25 changes: 1 addition & 24 deletions lib/unexpectedMitm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,6 @@ var messy = require('messy'),

var UnexpectedMitmMocker = require('./UnexpectedMitmMocker');

// fallback to an inlined version of 0.12+ path.isAbsolute() for 0.10 compat
var pathIsAbsolute = path.isAbsolute || function (path) {
var len = path.length;
if (len === 0) {
return false;
}
var code = path.charCodeAt(0);
if (code === 47/*/*/ || code === 92/*\*/) {
return true;
} else if ((code >= 65/*A*/ && code <= 90/*Z*/) ||
(code >= 97/*a*/ && code <= 122/*z*/)) {
// Possible device root

if (len > 2 && path.charCodeAt(1) === 58/*:*/) {
code = path.charCodeAt(2);
if (code === 47/*/*/ || code === 92/*\*/) {
return true;
}
}
}
return false;
};

function checkEnvFlag(varName) {
return process.env[varName] === 'true';
}
Expand Down Expand Up @@ -535,7 +512,7 @@ module.exports = {
var shouldReturnExtraInfo = expect.flags['with extra info'];
var writeCallsite = determineCallsite(callsite());

if (!pathIsAbsolute(testFile)) {
if (!path.isAbsolute(testFile)) {
testFile = path.join(path.dirname(writeCallsite.fileName), testFile);
}

Expand Down
21 changes: 7 additions & 14 deletions test/unexpectedMitm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ var pathModule = require('path'),
sinon = require('sinon'),
socketErrors = require('socketerrors-papandreou');

var isNodeZeroTen = !!process.version.match(/v0.10/);

function issueGetAndConsume(url, callback) {
http.get(url).on('response', function (response) {
var chunks = [];
Expand Down Expand Up @@ -183,11 +181,6 @@ describe('unexpectedMitm', function () {


it('should clean up properly after a keep-alived request with a custom Agent instance', function () {
if (isNodeZeroTen) {
// Seems like mitm doesn't support custom Agent instances with node.js 0.10
return this.skip();
}

var agent = new http.Agent({keepAlive: true});
return expect(function () {
return expect.promise(function (run) {
Expand Down Expand Up @@ -1625,31 +1618,31 @@ describe('unexpectedMitm', function () {

describe('in injecting mode against a local HTTP server', function () {
it('should record and inject', function () {
return expect('testfile', 'when injected becomes', isNodeZeroTen ? 'testfile-injected-v0_10' : 'testfile-injected');
return expect('testfile', 'when injected becomes', 'testfile-injected');
});

it('should record and inject textual injections', function () {
return expect('utf8file', 'when injected becomes', isNodeZeroTen ? 'utf8file-injected-v0_10' : 'utf8file-injected');
return expect('utf8file', 'when injected becomes', 'utf8file-injected');
});

it('should record and inject into a compound assertion', function () {
return expect('compound', 'when injected becomes', isNodeZeroTen ? 'compound-injected-v0_10' : 'compound-injected');
return expect('compound', 'when injected becomes', 'compound-injected');
});

it('should correctly handle buffer injections', function () {
return expect('bufferfile', 'when injected becomes', isNodeZeroTen ? 'bufferfile-injected-v0_10' : 'bufferfile-injected');
return expect('bufferfile', 'when injected becomes', 'bufferfile-injected');
});

it('should correctly handle long buffer injections (>32 octets should be base64 encoded)', function () {
return expect('longbufferfile', 'when injected becomes', isNodeZeroTen ? 'longbufferfile-injected-v0_10' : 'longbufferfile-injected');
return expect('longbufferfile', 'when injected becomes', 'longbufferfile-injected');
});

it('should correctly handle error injections', function () {
return expect('errorfile', 'when injected becomes', isNodeZeroTen ? 'errorfile-injected-v0_10' : 'errorfile-injected');
return expect('errorfile', 'when injected becomes', 'errorfile-injected');
});

it('should correctly handle multiple injections', function () {
return expect('multiplefile', 'when injected becomes', isNodeZeroTen ? 'multiplefile-injected-v0_10' : 'multiplefile-injected');
return expect('multiplefile', 'when injected becomes', 'multiplefile-injected');
});
});

Expand Down
44 changes: 0 additions & 44 deletions testdata/bufferfile-injected-v0_10.js

This file was deleted.

45 changes: 0 additions & 45 deletions testdata/compound-injected-v0_10.js

This file was deleted.

47 changes: 0 additions & 47 deletions testdata/errorfile-injected-v0_10.js

This file was deleted.

45 changes: 0 additions & 45 deletions testdata/longbufferfile-injected-v0_10.js

This file was deleted.

75 changes: 0 additions & 75 deletions testdata/multiplefile-injected-v0_10.js

This file was deleted.

0 comments on commit ade9c21

Please sign in to comment.