<commit_before>var request = require('request');

if (process.argv.length != 3) {
    throw new Error('expected one argument: [PORT]');
}

var URL = `http://127.0.0.1:${process.argv[2]}`;

function makeRequest(method, path, body, headers, callback) {
    request({
        method: method,
        url: `${URL}${path}`,
        json: true,
        body: body,
        headers: headers,
    }, (error, response, body) => {
        if (error) { throw error; }
        if (response.statusCode != 200) { throw new Error(JSON.stringify({ code: response.statusCode, body: response.body })); }
        if (callback) { callback(body); }
    });
}

function addUser(email, password, callback) {
    makeRequest('POST', '/accounts', { email: email, password: password }, null, callback);
}

function addFile(folder, name, mime, size, created) {
    let body = {
        region: 'us-east-1',
        accessKeyID: 'TOPSECRET',
        secretAccessKey: 'TOPSECRET',
        folder: folder,
        name: name,
        mime: mime,
        size: size,
        created: created,
        s3: `s3://sekurearchive/${folder}/${name}`,
    };
    makeRequest('POST', '/files', body, null);
}

function addFolder(authorization, path) {
    let headers = { authorization: `Bearer ${authorization}` };
    makeRequest('POST', '/folders', { path: path }, headers, (body) => {
        addFile(path, 'a.txt', 'text/plain', 1011, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 1512341, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 1241235123, '2017-03-19 04:19');
        addFile(path, 'a.txt', 'text/plain', 2051, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 2512315, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 2184123891, '2017-03-19 04:19');
        addFile(path, 'a.txt', 'text/plain', 4051, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 4012312, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 4512351233, '2017-03-19 04:19');
        addFile(path, 'a.txt', 'text/plain', 8141, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 8151233, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 8912581274, '2017-03-19 04:19');<commit_msg>Fix S3 links in test data<commit_after>var request = require('request');

if (process.argv.length != 3) {
    throw new Error('expected one argument: [PORT]');
}

var URL = `http://127.0.0.1:${process.argv[2]}`;

function makeRequest(method, path, body, headers, callback) {
    request({
        method: method,
        url: `${URL}${path}`,
        json: true,
        body: body,
        headers: headers,
    }, (error, response, body) => {
        if (error) { throw error; }
        if (response.statusCode != 200) { throw new Error(JSON.stringify({ code: response.statusCode, body: response.body })); }
        if (callback) { callback(body); }
    });
}

function addUser(email, password, callback) {
    makeRequest('POST', '/accounts', { email: email, password: password }, null, callback);
}

function addFile(folder, name, mime, size, created) {
    let body = {
        region: 'us-east-1',
        accessKeyID: 'TOPSECRET',
        secretAccessKey: 'TOPSECRET',
        folder: folder,
        name: name,
        mime: mime,
        size: size,
        created: created,
        s3: `s3://sekurearchive${folder}/${name}`,
    };
    makeRequest('POST', '/files', body, null);
}

function addFolder(authorization, path) {
    let headers = { authorization: `Bearer ${authorization}` };
    makeRequest('POST', '/folders', { path: path }, headers, (body) => {
        addFile(path, 'a.txt', 'text/plain', 1011, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 1512341, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 1241235123, '2017-03-19 04:19');
        addFile(path, 'a.txt', 'text/plain', 2051, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 2512315, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 2184123891, '2017-03-19 04:19');
        addFile(path, 'a.txt', 'text/plain', 4051, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 4012312, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 4512351233, '2017-03-19 04:19');
        addFile(path, 'a.txt', 'text/plain', 8141, '2017-03-19 04:17');
        addFile(path, 'b.txt', 'text/plain', 8151233, '2017-03-19 04:18');
        addFile(path, 'c.txt', 'text/plain', 8912581274, '2017-03-19 04:19');
{'fraction_non_alphanumeric': 0.19699977939554378, 'fraction_numerical': 0.10699316126185748, 'mean_word_length': 3.015943312666076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1311392', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1599, 'n_words': 364}