<commit_before>require("../lib/jasmine-promise");
var Q = require("q");
var HTTPS = require("https");
var http = require('../../http');

describe("https agent", function () {

    it("should allow use self-signed certificate", function () {
        var options = {
            passphrase: '<PASSWORD>',
            key: '-----BEGIN RSA PRIVATE KEY-----\n' +
'Proc-Type: 4,ENCRYPTED\n' +
'DEK-Info: DES-EDE3-CBC,6ACDE0E22CA24B54\n' +
'\n' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'/<KEY>' +
'MXP1PHZnzbhEkV01bRL0+keQuS3gd+<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'-----END RSA PRIVATE KEY-----\n',
            cert: '-----BEGIN CERTIFICATE-----\n' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>dHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n' +
'<KEY>n' +
'ipKvD+bnVgR8asql8AutHzaiCr6yOxUfs9gRgJ37TQGmTFpKx5/OegV2t7khq8Uc\n' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'89Yb8/2e/5CzxW4LAMNRqD5GwKE=\n' +
'-----END CERTIFICATE-----\n'
        };

        var server = HTTPS.createServer(options, function (req, res) {
            res.writeHead(200, {
                'Content-Type': 'text/plain',
                'Content-Length': 2
            });
            res.end('ok');
        });

        server.listen(0);

        var port = server.address().port;

        var agent = new HTTPS.Agent({
            rejectUnauthorized: false
        });

        var request = {
            "host": "localhost",
            "port": port,
            "ssl": true,
            "agent": agent
        };

        return http.request(request)
        .then(function (response) {
            expect(Q.isPromise(response.body)).toBe(false);
            var acc = [];
            return response.body.read()<commit_msg>remove unnecessary variables in specs<commit_after>require("../lib/jasmine-promise");
var Q = require("q");
var HTTPS = require("https");
var http = require('../../http');

describe("https agent", function () {

    it("should allow use self-signed certificate", function () {
        var options = {
            passphrase: '<PASSWORD>',
            key: '-----BEGIN RSA PRIVATE KEY-----\n' +
'Proc-Type: 4,ENCRYPTED\n' +
'DEK-Info: DES-EDE3-CBC,6ACDE0E22CA24B54\n' +
'\n' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'/<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'-----END RSA PRIVATE KEY-----\n',
            cert: '-----BEGIN CERTIFICATE-----\n' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>' +
'<KEY>DQYJKoZIhvcNAQEFBQADgYEAMw8bTEPx+rlIxTMR\n' +
'rvZriPeMzlh45vhRyy7JO1C+RnzSVBWUyL/Ca7QbrFcq4nGai2xFnqEEiPKWrP8b\n' +
've1oBz9V18gv6T4oiqOpFmoh2c/IVNr2qE01GdGIos/wb1cYEFRsMLPplbv4PROR\n' +
'89Yb8/2e/5CzxW4LAMNRqD5GwKE=\n' +
'-----END CERTIFICATE-----\n'
        };

        var server = HTTPS.createServer(options, function (req, res) {
            res.writeHead(200, {
                'Content-Type': 'text/plain',
                'Content-Length': 2
            });
            res.end('ok');
        });

        server.listen(0);

        var port = server.address().port;

        var agent = new HTTPS.Agent({
            rejectUnauthorized: false
        });

        var request = {
            "host": "localhost",
            "port": port,
            "ssl": true,
            "agent": agent
        };

        return http.request(request)
        .then(function (response) {
            expect(Q.isPromise(response.body)).toBe(false);
            return response.body.read()
{'fraction_non_alphanumeric': 0.21592821088053843, 'fraction_numerical': 0.02327537857543466, 'mean_word_length': 2.196236559139785, 'pattern_counts': {'":': 8, '<': 56, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5684782', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1382, 'n_words': 223}