New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@smartbear/one-report-publisher

Package Overview
Dependencies
Maintainers
14
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smartbear/one-report-publisher - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

31

dist/cjs/src/action/index.js

@@ -54,5 +54,4 @@ "use strict";

var core_1 = __importDefault(require("@actions/core"));
var url_1 = require("url");
var index_js_1 = require("../../src/index.js");
var organizationId = core_1.default.getInput('organization') || process.env.ONE_REPORT_ORGANIZATION;
var projectId = core_1.default.getInput('project-id') || process.env.ONE_REPORT_PROJECT_ID;
var token = core_1.default.getInput('token') || process.env.ONE_REPORT_TOKEN;

@@ -70,4 +69,4 @@ var baseUrl = core_1.default.getInput('url') || process.env.ONE_REPORT_URL;

case 0:
if (!organizationId)
throw new Error("Please specify 'organization' or define the ONE_REPORT_ORGANIZATION environment variable");
if (!projectId)
throw new Error("Please specify 'project-id' or define the ONE_REPORT_PROJECT_ID environment variable");
if (!token)

@@ -78,8 +77,6 @@ throw new Error("Please specify 'token' or define the ONE_REPORT_TOKEN environment variable");

requestTimeout = maxTime ? +maxTime * 1000 : undefined;
return [4 /*yield*/, (0, index_js_1.publish)(globs, zip, organizationId, baseUrl, process.env, (0, index_js_1.tokenAuthenticator)(token), requestTimeout)];
return [4 /*yield*/, (0, index_js_1.publish)(globs, zip, projectId, baseUrl, process.env, (0, index_js_1.tokenAuthenticator)(token), requestTimeout)];
case 1:
responseBodies = _a.sent();
return [2 /*return*/, responseBodies.map(function (body) {
return new url_1.URL("/organization/".concat(organizationId, "/test-cycles/").concat(body.testCycleId), baseUrl).toString();
})];
return [2 /*return*/, responseBodies.map(function (body) { return body.testCycleId; })];
}

@@ -90,12 +87,12 @@ });

main()
.then(function (reportUrls) {
.then(function (testCycleIds) {
var e_1, _a;
// Set report URLs as output, in case someone wants to do something special with them
core_1.default.setOutput('report-urls', reportUrls);
// Also print each URL, for convenience
core_1.default.startGroup('Report URLs');
// Set test cycle ids as output, in case someone wants to do something special with them
core_1.default.setOutput('test-cycle-ids', testCycleIds);
// Also print each test cycle id, for convenience
core_1.default.startGroup('Test Cycle Ids');
try {
for (var reportUrls_1 = __values(reportUrls), reportUrls_1_1 = reportUrls_1.next(); !reportUrls_1_1.done; reportUrls_1_1 = reportUrls_1.next()) {
var reportUrl = reportUrls_1_1.value;
core_1.default.info(reportUrl);
for (var testCycleIds_1 = __values(testCycleIds), testCycleIds_1_1 = testCycleIds_1.next(); !testCycleIds_1_1.done; testCycleIds_1_1 = testCycleIds_1.next()) {
var testCycleId = testCycleIds_1_1.value;
core_1.default.info(testCycleId);
}

@@ -106,3 +103,3 @@ }

try {
if (reportUrls_1_1 && !reportUrls_1_1.done && (_a = reportUrls_1.return)) _a.call(reportUrls_1);
if (testCycleIds_1_1 && !testCycleIds_1_1.done && (_a = testCycleIds_1.return)) _a.call(testCycleIds_1);
}

@@ -109,0 +106,0 @@ finally { if (e_1) throw e_1.error; }

@@ -39,20 +39,8 @@ #!/usr/bin/env node

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
var commander_1 = require("commander");
var url_1 = require("url");
var index_js_1 = require("../../src/index.js");
var program = new commander_1.Command();
program.requiredOption('-u, --url <url>', 'OneReport URL. Defaults to $ONE_REPORT_URL', process.env.ONE_REPORT_URL);
program.requiredOption('-o, --organization <id>', 'OneReport organization id. Defaults to $ONE_REPORT_ORGANIZATION', process.env.ONE_REPORT_ORGANIZATION);
program.requiredOption('-p, --project-id <id>', 'OneReport project id. Defaults to $ONE_REPORT_PROJECT_ID', process.env.ONE_REPORT_PROJECT_ID);
program.requiredOption('-t, --token <token>', 'OneReport token. Defaults to $ONE_REPORT_TOKEN', process.env.ONE_REPORT_TOKEN);

@@ -64,3 +52,3 @@ program.requiredOption('-r, --reports <glob...>', 'Glob to the files to publish');

program.parse(process.argv);
var _a = program.opts(), organization = _a.organization, token = _a.token, globs = _a.reports, maxTime = _a.maxTime, ignoreError = _a.ignoreError, baseUrl = _a.url, noZip = _a.noZip;
var _a = program.opts(), projectId = _a.projectId, token = _a.token, globs = _a.reports, maxTime = _a.maxTime, ignoreError = _a.ignoreError, baseUrl = _a.url, noZip = _a.noZip;
function main() {

@@ -73,8 +61,6 @@ return __awaiter(this, void 0, void 0, function () {

requestTimeout = maxTime ? +maxTime * 1000 : undefined;
return [4 /*yield*/, (0, index_js_1.publish)(globs, !noZip, organization, baseUrl, process.env, (0, index_js_1.tokenAuthenticator)(token), requestTimeout)];
return [4 /*yield*/, (0, index_js_1.publish)(globs, !noZip, projectId, baseUrl, process.env, (0, index_js_1.tokenAuthenticator)(token), requestTimeout)];
case 1:
responseBodies = _a.sent();
return [2 /*return*/, responseBodies.map(function (body) {
return new url_1.URL("/organization/".concat(organization, "/test-cycles/").concat(body.testCycleId), baseUrl).toString();
})];
return [2 /*return*/, responseBodies.map(function (body) { return body.testCycleId; })];
}

@@ -85,18 +71,5 @@ });

main()
.then(function (reportUrls) {
var e_1, _a;
console.log('Report URLs');
try {
for (var reportUrls_1 = __values(reportUrls), reportUrls_1_1 = reportUrls_1.next(); !reportUrls_1_1.done; reportUrls_1_1 = reportUrls_1.next()) {
var reportUrl = reportUrls_1_1.value;
console.log("- ".concat(reportUrl));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (reportUrls_1_1 && !reportUrls_1_1.done && (_a = reportUrls_1.return)) _a.call(reportUrls_1);
}
finally { if (e_1) throw e_1.error; }
}
.then(function (testCycleIds) {
console.log('Test Cycle Ids');
console.log(testCycleIds);
})

@@ -103,0 +76,0 @@ .catch(function (error) {

@@ -8,3 +8,3 @@ import { Env } from '@cucumber/ci-environment';

* @param zip if true, compress all non .zip files into a zip file before publishing
* @param organizationId the Organization ID on OneReport
* @param projectId the Project ID on OneReport
* @param baseUrl the base URL of OneReport

@@ -16,3 +16,3 @@ * @param env the local environment, e.g. process.env (used to detect Git info from env vars set by CI)

*/
export declare function publish<ResponseBody>(globs: readonly string[], zip: boolean, organizationId: string, baseUrl: string, env: Env, authenticate: Authenticate, requestTimeout: number | undefined): Promise<readonly ResponseBody[]>;
export declare function publish<ResponseBody>(globs: readonly string[], zip: boolean, projectId: string, baseUrl: string, env: Env, authenticate: Authenticate, requestTimeout: number | undefined): Promise<readonly ResponseBody[]>;
//# sourceMappingURL=publish.d.ts.map

@@ -94,3 +94,3 @@ "use strict";

* @param zip if true, compress all non .zip files into a zip file before publishing
* @param organizationId the Organization ID on OneReport
* @param projectId the Project ID on OneReport
* @param baseUrl the base URL of OneReport

@@ -102,3 +102,3 @@ * @param env the local environment, e.g. process.env (used to detect Git info from env vars set by CI)

*/
function publish(globs, zip, organizationId, baseUrl, env, authenticate, requestTimeout) {
function publish(globs, zip, projectId, baseUrl, env, authenticate, requestTimeout) {
return __awaiter(this, void 0, void 0, function () {

@@ -116,3 +116,3 @@ var authHeaders, url, ciEnv, paths, publishPaths, _a;

authHeaders = authenticate();
url = new url_1.URL("/api/organization/".concat(encodeURIComponent(organizationId), "/test-cycle"), baseUrl);
url = new url_1.URL("/api/project/".concat(encodeURIComponent(projectId), "/test-cycle"), baseUrl);
ciEnv = (0, ci_environment_1.default)(env);

@@ -166,23 +166,26 @@ return [4 /*yield*/, (0, manyglob_js_1.manyglob)(globs)];

}, function (res) {
if (res.statusCode !== 201) {
return reject(new Error("Unexpected status code ".concat(res.statusCode, "\nPOST ").concat(url.toString(), " -d @").concat(path, "\n> ").concat(Object.entries(headers)
.map(function (_a) {
var _b = __read(_a, 2), h = _b[0], v = _b[1];
return "".concat(h, ": ").concat(v);
})
.join('\n> '), "\n\n< ").concat(Object.entries(res.headers)
.map(function (_a) {
var _b = __read(_a, 2), h = _b[0], v = _b[1];
return "".concat(h, ": ").concat(v);
})
.join('\n< '), "\n")));
}
(0, readStream_js_1.readStream)(res)
.then(function (buffer) {
try {
var responseBody = JSON.parse(buffer.toString('utf-8'));
return resolve(responseBody);
.then(function (buffer) { return buffer.toString('utf-8'); })
.then(function (body) {
if (res.statusCode !== 201) {
return reject(new Error("Unexpected status code ".concat(res.statusCode, "\nPOST ").concat(url.toString(), " -d @").concat(path, "\n> ").concat(Object.entries(headers)
.map(function (_a) {
var _b = __read(_a, 2), h = _b[0], v = _b[1];
return "".concat(h, ": ").concat(v);
})
.join('\n> '), "\n\n< ").concat(Object.entries(res.headers)
.map(function (_a) {
var _b = __read(_a, 2), h = _b[0], v = _b[1];
return "".concat(h, ": ").concat(v);
})
.join('\n< '), "\n\n").concat(body, "\n")));
}
catch (err) {
reject(err);
else {
try {
var responseBody = JSON.parse(body);
return resolve(responseBody);
}
catch (err) {
reject(err);
}
}

@@ -189,0 +192,0 @@ })

@@ -55,2 +55,3 @@ "use strict";

var serverLatency;
var responseDate;
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {

@@ -61,2 +62,3 @@ return __generator(this, function (_a) {

serverLatency = 0;
responseDate = new Date(Date.now() - 1000).toUTCString();
return [4 /*yield*/, new Promise(function (resolve) {

@@ -72,3 +74,10 @@ server = http_1.default.createServer(function (req, res) {

});
res.statusCode = 201;
res.setHeader('Date', responseDate);
if (!req.headers.authorization) {
res.statusCode = 401;
return res.end('You need to authenticate');
}
else {
res.statusCode = 201;
}
var responseBody = {

@@ -104,3 +113,3 @@ hello: 'world',

it('times out after specified timeout', function () { return __awaiter(void 0, void 0, void 0, function () {
var organizationId, fakeEnv;
var projectId, fakeEnv;
return __generator(this, function (_a) {

@@ -110,3 +119,3 @@ switch (_a.label) {

serverLatency = 10;
organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
fakeEnv = {

@@ -119,3 +128,3 @@ GITHUB_SERVER_URL: 'https://github.com',

};
return [4 /*yield*/, assert_1.default.rejects((0, index_js_1.publish)(['test/fixtures/*.xml'], false, organizationId, "http://localhost:".concat(port), fakeEnv, function () { return ({}); }, 1))];
return [4 /*yield*/, assert_1.default.rejects((0, index_js_1.publish)(['test/fixtures/*.xml'], false, projectId, "http://localhost:".concat(port), fakeEnv, function () { return ({}); }, 1))];
case 1:

@@ -128,3 +137,3 @@ _a.sent();

it('publishes files from glob without zipping', function () { return __awaiter(void 0, void 0, void 0, function () {
var organizationId, fakeEnv, responseBodies, expectedServerRequests, _a, _b, _c, _d, _e, _f, _g, _h, _j, sortedServerRequests, sortedExpectedServerRequests, expectedResponseBodies;
var projectId, fakeEnv, responseBodies, expectedServerRequests, _a, _b, _c, _d, _e, _f, _g, _h, _j, sortedServerRequests, sortedExpectedServerRequests, expectedResponseBodies;
var _k, _l, _m, _o, _p, _q, _r, _s;

@@ -134,3 +143,3 @@ return __generator(this, function (_t) {

case 0:
organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
fakeEnv = {

@@ -143,7 +152,7 @@ GITHUB_SERVER_URL: 'https://github.com',

};
return [4 /*yield*/, (0, index_js_1.publish)(['test/fixtures/*.{xml,json,ndjson,zip}'], false, organizationId, "http://localhost:".concat(port), fakeEnv, function () { return ({}); }, undefined)];
return [4 /*yield*/, (0, index_js_1.publish)(['test/fixtures/*.{xml,json,ndjson,zip}'], false, projectId, "http://localhost:".concat(port), fakeEnv, function () { return ({ Authorization: 'Bearer goodToken' }); }, undefined)];
case 1:
responseBodies = _t.sent();
_k = {
url: "/api/organization/".concat(organizationId, "/test-cycle")
url: "/api/project/".concat(projectId, "/test-cycle")
};

@@ -163,2 +172,3 @@ _l = {

_l['onereport-branch'] = 'main',
_l.authorization = 'Bearer goodToken',
_l);

@@ -172,3 +182,3 @@ return [4 /*yield*/, readFile('test/fixtures/cucumber.json')];

_m = {
url: "/api/organization/".concat(organizationId, "/test-cycle")
url: "/api/project/".concat(projectId, "/test-cycle")
};

@@ -188,2 +198,3 @@ _o = {

_o['onereport-branch'] = 'main',
_o.authorization = 'Bearer goodToken',
_o);

@@ -197,3 +208,3 @@ return [4 /*yield*/, readFile('test/fixtures/junit.xml')];

_p = {
url: "/api/organization/".concat(organizationId, "/test-cycle")
url: "/api/project/".concat(projectId, "/test-cycle")
};

@@ -213,2 +224,3 @@ _q = {

_q['onereport-branch'] = 'main',
_q.authorization = 'Bearer goodToken',
_q);

@@ -222,3 +234,3 @@ return [4 /*yield*/, readFile('test/fixtures/cucumber.ndjson')];

_r = {
url: "/api/organization/".concat(organizationId, "/test-cycle")
url: "/api/project/".concat(projectId, "/test-cycle")
};

@@ -238,2 +250,3 @@ _s = {

_s['onereport-branch'] = 'main',
_s.authorization = 'Bearer goodToken',
_s);

@@ -269,9 +282,9 @@ return [4 /*yield*/, readFile('test/fixtures/bundled.zip')];

it('publishes files from glob with zipping', function () { return __awaiter(void 0, void 0, void 0, function () {
var organizationId, fakeEnv, responseBodies, expectedServerRequests, sortedServerRequests, sortedExpectedServerRequests, expectedResponseBodies;
var projectId, fakeEnv, responseBodies, expectedServerRequests, sortedServerRequests, sortedExpectedServerRequests, expectedResponseBodies;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
fakeEnv = {};
return [4 /*yield*/, (0, index_js_1.publish)(['test/fixtures/*.{xml,json,ndjson,zip}'], true, organizationId, "http://localhost:".concat(port), fakeEnv, function () { return ({}); }, undefined)];
return [4 /*yield*/, (0, index_js_1.publish)(['test/fixtures/*.{xml,json,ndjson,zip}'], true, projectId, "http://localhost:".concat(port), fakeEnv, function () { return ({ Authorization: 'Bearer goodToken' }); }, undefined)];
case 1:

@@ -281,3 +294,3 @@ responseBodies = _a.sent();

{
url: "/api/organization/".concat(organizationId, "/test-cycle"),
url: "/api/project/".concat(projectId, "/test-cycle"),
headers: {

@@ -287,6 +300,7 @@ 'content-type': 'application/zip',

host: "localhost:".concat(port),
authorization: 'Bearer goodToken',
},
},
{
url: "/api/organization/".concat(organizationId, "/test-cycle"),
url: "/api/project/".concat(projectId, "/test-cycle"),
headers: {

@@ -296,2 +310,3 @@ 'content-type': 'application/zip',

host: "localhost:".concat(port),
authorization: 'Bearer goodToken',
},

@@ -325,2 +340,26 @@ },

}); });
it('prints response headers if response is not 201', function () { return __awaiter(void 0, void 0, void 0, function () {
var projectId, fakeEnv;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
fakeEnv = {
GITHUB_SERVER_URL: 'https://github.com',
GITHUB_REPOSITORY: 'SmartBear/one-report-publisher',
GITHUB_RUN_ID: '154666429',
GITHUB_SHA: 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c',
GITHUB_HEAD_REF: 'main',
};
return [4 /*yield*/, assert_1.default.rejects(function () {
return (0, index_js_1.publish)(['test/fixtures/*.xml'], false, projectId, "http://localhost:".concat(port), fakeEnv, function () { return ({}); }, undefined);
}, {
message: "Unexpected status code 401\nPOST http://localhost:".concat(port, "/api/project/32C46057-0AB6-44E8-8944-0246E0BEA96F/test-cycle -d @test/fixtures/junit.xml\n> Content-Type: text/xml\n> Content-Length: 359\n> OneReport-SourceControl: https://github.com/SmartBear/one-report-publisher.git\n> OneReport-Revision: f7d967d6d4f7adc1d6657bda88f4e976c879d74c\n> OneReport-Branch: main\n\n< date: ").concat(responseDate, "\n< connection: close\n< content-length: 24\n\nYou need to authenticate\n"),
})];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); });
});

@@ -327,0 +366,0 @@ // Requests are sent in parallel, so we don't know what request hit the server first.

@@ -11,5 +11,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import core from '@actions/core';
import { URL } from 'url';
import { publish, tokenAuthenticator } from '../../src/index.js';
const organizationId = core.getInput('organization') || process.env.ONE_REPORT_ORGANIZATION;
const projectId = core.getInput('project-id') || process.env.ONE_REPORT_PROJECT_ID;
const token = core.getInput('token') || process.env.ONE_REPORT_TOKEN;

@@ -23,4 +22,4 @@ const baseUrl = core.getInput('url') || process.env.ONE_REPORT_URL;

return __awaiter(this, void 0, void 0, function* () {
if (!organizationId)
throw new Error("Please specify 'organization' or define the ONE_REPORT_ORGANIZATION environment variable");
if (!projectId)
throw new Error("Please specify 'project-id' or define the ONE_REPORT_PROJECT_ID environment variable");
if (!token)

@@ -31,14 +30,14 @@ throw new Error("Please specify 'token' or define the ONE_REPORT_TOKEN environment variable");

const requestTimeout = maxTime ? +maxTime * 1000 : undefined;
const responseBodies = yield publish(globs, zip, organizationId, baseUrl, process.env, tokenAuthenticator(token), requestTimeout);
return responseBodies.map((body) => new URL(`/organization/${organizationId}/test-cycles/${body.testCycleId}`, baseUrl).toString());
const responseBodies = yield publish(globs, zip, projectId, baseUrl, process.env, tokenAuthenticator(token), requestTimeout);
return responseBodies.map((body) => body.testCycleId);
});
}
main()
.then((reportUrls) => {
// Set report URLs as output, in case someone wants to do something special with them
core.setOutput('report-urls', reportUrls);
// Also print each URL, for convenience
core.startGroup('Report URLs');
for (const reportUrl of reportUrls) {
core.info(reportUrl);
.then((testCycleIds) => {
// Set test cycle ids as output, in case someone wants to do something special with them
core.setOutput('test-cycle-ids', testCycleIds);
// Also print each test cycle id, for convenience
core.startGroup('Test Cycle Ids');
for (const testCycleId of testCycleIds) {
core.info(testCycleId);
}

@@ -45,0 +44,0 @@ core.endGroup();

@@ -12,7 +12,6 @@ #!/usr/bin/env node

import { Command } from 'commander';
import { URL } from 'url';
import { publish, tokenAuthenticator } from '../../src/index.js';
const program = new Command();
program.requiredOption('-u, --url <url>', 'OneReport URL. Defaults to $ONE_REPORT_URL', process.env.ONE_REPORT_URL);
program.requiredOption('-o, --organization <id>', 'OneReport organization id. Defaults to $ONE_REPORT_ORGANIZATION', process.env.ONE_REPORT_ORGANIZATION);
program.requiredOption('-p, --project-id <id>', 'OneReport project id. Defaults to $ONE_REPORT_PROJECT_ID', process.env.ONE_REPORT_PROJECT_ID);
program.requiredOption('-t, --token <token>', 'OneReport token. Defaults to $ONE_REPORT_TOKEN', process.env.ONE_REPORT_TOKEN);

@@ -24,16 +23,14 @@ program.requiredOption('-r, --reports <glob...>', 'Glob to the files to publish');

program.parse(process.argv);
const { organization, token, reports: globs, maxTime, ignoreError, url: baseUrl, noZip, } = program.opts();
const { projectId, token, reports: globs, maxTime, ignoreError, url: baseUrl, noZip, } = program.opts();
function main() {
return __awaiter(this, void 0, void 0, function* () {
const requestTimeout = maxTime ? +maxTime * 1000 : undefined;
const responseBodies = yield publish(globs, !noZip, organization, baseUrl, process.env, tokenAuthenticator(token), requestTimeout);
return responseBodies.map((body) => new URL(`/organization/${organization}/test-cycles/${body.testCycleId}`, baseUrl).toString());
const responseBodies = yield publish(globs, !noZip, projectId, baseUrl, process.env, tokenAuthenticator(token), requestTimeout);
return responseBodies.map((body) => body.testCycleId);
});
}
main()
.then((reportUrls) => {
console.log('Report URLs');
for (const reportUrl of reportUrls) {
console.log(`- ${reportUrl}`);
}
.then((testCycleIds) => {
console.log('Test Cycle Ids');
console.log(testCycleIds);
})

@@ -40,0 +37,0 @@ .catch((error) => {

@@ -8,3 +8,3 @@ import { Env } from '@cucumber/ci-environment';

* @param zip if true, compress all non .zip files into a zip file before publishing
* @param organizationId the Organization ID on OneReport
* @param projectId the Project ID on OneReport
* @param baseUrl the base URL of OneReport

@@ -16,3 +16,3 @@ * @param env the local environment, e.g. process.env (used to detect Git info from env vars set by CI)

*/
export declare function publish<ResponseBody>(globs: readonly string[], zip: boolean, organizationId: string, baseUrl: string, env: Env, authenticate: Authenticate, requestTimeout: number | undefined): Promise<readonly ResponseBody[]>;
export declare function publish<ResponseBody>(globs: readonly string[], zip: boolean, projectId: string, baseUrl: string, env: Env, authenticate: Authenticate, requestTimeout: number | undefined): Promise<readonly ResponseBody[]>;
//# sourceMappingURL=publish.d.ts.map

@@ -34,3 +34,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

* @param zip if true, compress all non .zip files into a zip file before publishing
* @param organizationId the Organization ID on OneReport
* @param projectId the Project ID on OneReport
* @param baseUrl the base URL of OneReport

@@ -42,3 +42,3 @@ * @param env the local environment, e.g. process.env (used to detect Git info from env vars set by CI)

*/
export function publish(globs, zip, organizationId, baseUrl, env, authenticate, requestTimeout) {
export function publish(globs, zip, projectId, baseUrl, env, authenticate, requestTimeout) {
return __awaiter(this, void 0, void 0, function* () {

@@ -52,3 +52,3 @@ if (!Array.isArray(globs)) {

const authHeaders = authenticate();
const url = new URL(`/api/organization/${encodeURIComponent(organizationId)}/test-cycle`, baseUrl);
const url = new URL(`/api/project/${encodeURIComponent(projectId)}/test-cycle`, baseUrl);
const ciEnv = ciEnvironment(env);

@@ -87,22 +87,27 @@ const paths = (yield manyglob(globs))

}, (res) => {
if (res.statusCode !== 201) {
return reject(new Error(`Unexpected status code ${res.statusCode}
readStream(res)
.then((buffer) => buffer.toString('utf-8'))
.then((body) => {
if (res.statusCode !== 201) {
return reject(new Error(`Unexpected status code ${res.statusCode}
POST ${url.toString()} -d @${path}
> ${Object.entries(headers)
.map(([h, v]) => `${h}: ${v}`)
.join('\n> ')}
.map(([h, v]) => `${h}: ${v}`)
.join('\n> ')}
< ${Object.entries(res.headers)
.map(([h, v]) => `${h}: ${v}`)
.join('\n< ')}
.map(([h, v]) => `${h}: ${v}`)
.join('\n< ')}
${body}
`));
}
readStream(res)
.then((buffer) => {
try {
const responseBody = JSON.parse(buffer.toString('utf-8'));
return resolve(responseBody);
}
catch (err) {
reject(err);
else {
try {
const responseBody = JSON.parse(body);
return resolve(responseBody);
}
catch (err) {
reject(err);
}
}

@@ -109,0 +114,0 @@ })

@@ -23,4 +23,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

let serverLatency;
let responseDate;
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
serverLatency = 0;
responseDate = new Date(Date.now() - 1000).toUTCString();
port = yield new Promise((resolve) => {

@@ -36,3 +38,10 @@ server = http.createServer((req, res) => {

});
res.statusCode = 201;
res.setHeader('Date', responseDate);
if (!req.headers.authorization) {
res.statusCode = 401;
return res.end('You need to authenticate');
}
else {
res.statusCode = 201;
}
const responseBody = {

@@ -62,3 +71,3 @@ hello: 'world',

serverLatency = 10;
const organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const fakeEnv = {

@@ -71,6 +80,6 @@ GITHUB_SERVER_URL: 'https://github.com',

};
yield assert.rejects(publish(['test/fixtures/*.xml'], false, organizationId, `http://localhost:${port}`, fakeEnv, () => ({}), 1));
yield assert.rejects(publish(['test/fixtures/*.xml'], false, projectId, `http://localhost:${port}`, fakeEnv, () => ({}), 1));
}));
it('publishes files from glob without zipping', () => __awaiter(void 0, void 0, void 0, function* () {
const organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const fakeEnv = {

@@ -83,6 +92,6 @@ GITHUB_SERVER_URL: 'https://github.com',

};
const responseBodies = yield publish(['test/fixtures/*.{xml,json,ndjson,zip}'], false, organizationId, `http://localhost:${port}`, fakeEnv, () => ({}), undefined);
const responseBodies = yield publish(['test/fixtures/*.{xml,json,ndjson,zip}'], false, projectId, `http://localhost:${port}`, fakeEnv, () => ({ Authorization: 'Bearer goodToken' }), undefined);
const expectedServerRequests = [
{
url: `/api/organization/${organizationId}/test-cycle`,
url: `/api/project/${projectId}/test-cycle`,
headers: {

@@ -96,2 +105,3 @@ 'content-type': 'application/json',

'onereport-branch': 'main',
authorization: 'Bearer goodToken',
},

@@ -101,3 +111,3 @@ body: yield readFile('test/fixtures/cucumber.json'),

{
url: `/api/organization/${organizationId}/test-cycle`,
url: `/api/project/${projectId}/test-cycle`,
headers: {

@@ -111,2 +121,3 @@ 'content-type': 'text/xml',

'onereport-branch': 'main',
authorization: 'Bearer goodToken',
},

@@ -116,3 +127,3 @@ body: yield readFile('test/fixtures/junit.xml'),

{
url: `/api/organization/${organizationId}/test-cycle`,
url: `/api/project/${projectId}/test-cycle`,
headers: {

@@ -126,2 +137,3 @@ 'content-type': 'application/x-ndjson',

'onereport-branch': 'main',
authorization: 'Bearer goodToken',
},

@@ -131,3 +143,3 @@ body: yield readFile('test/fixtures/cucumber.ndjson'),

{
url: `/api/organization/${organizationId}/test-cycle`,
url: `/api/project/${projectId}/test-cycle`,
headers: {

@@ -141,2 +153,3 @@ 'content-type': 'application/zip',

'onereport-branch': 'main',
authorization: 'Bearer goodToken',
},

@@ -166,8 +179,8 @@ body: yield readFile('test/fixtures/bundled.zip'),

it('publishes files from glob with zipping', () => __awaiter(void 0, void 0, void 0, function* () {
const organizationId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const fakeEnv = {};
const responseBodies = yield publish(['test/fixtures/*.{xml,json,ndjson,zip}'], true, organizationId, `http://localhost:${port}`, fakeEnv, () => ({}), undefined);
const responseBodies = yield publish(['test/fixtures/*.{xml,json,ndjson,zip}'], true, projectId, `http://localhost:${port}`, fakeEnv, () => ({ Authorization: 'Bearer goodToken' }), undefined);
const expectedServerRequests = [
{
url: `/api/organization/${organizationId}/test-cycle`,
url: `/api/project/${projectId}/test-cycle`,
headers: {

@@ -177,6 +190,7 @@ 'content-type': 'application/zip',

host: `localhost:${port}`,
authorization: 'Bearer goodToken',
},
},
{
url: `/api/organization/${organizationId}/test-cycle`,
url: `/api/project/${projectId}/test-cycle`,
headers: {

@@ -186,2 +200,3 @@ 'content-type': 'application/zip',

host: `localhost:${port}`,
authorization: 'Bearer goodToken',
},

@@ -212,2 +227,28 @@ },

}));
it('prints response headers if response is not 201', () => __awaiter(void 0, void 0, void 0, function* () {
const projectId = '32C46057-0AB6-44E8-8944-0246E0BEA96F';
const fakeEnv = {
GITHUB_SERVER_URL: 'https://github.com',
GITHUB_REPOSITORY: 'SmartBear/one-report-publisher',
GITHUB_RUN_ID: '154666429',
GITHUB_SHA: 'f7d967d6d4f7adc1d6657bda88f4e976c879d74c',
GITHUB_HEAD_REF: 'main',
};
yield assert.rejects(() => publish(['test/fixtures/*.xml'], false, projectId, `http://localhost:${port}`, fakeEnv, () => ({}), undefined), {
message: `Unexpected status code 401
POST http://localhost:${port}/api/project/32C46057-0AB6-44E8-8944-0246E0BEA96F/test-cycle -d @test/fixtures/junit.xml
> Content-Type: text/xml
> Content-Length: 359
> OneReport-SourceControl: https://github.com/SmartBear/one-report-publisher.git
> OneReport-Revision: f7d967d6d4f7adc1d6657bda88f4e976c879d74c
> OneReport-Branch: main
< date: ${responseDate}
< connection: close
< content-length: 24
You need to authenticate
`,
});
}));
});

@@ -214,0 +255,0 @@ // Requests are sent in parallel, so we don't know what request hit the server first.

{
"name": "@smartbear/one-report-publisher",
"version": "0.5.0",
"version": "0.6.0",
"description": "Publish Test Results to SmartBear OneReport",

@@ -57,11 +57,11 @@ "type": "module",

"@types/mocha": "9.1.1",
"@types/node": "18.0.0",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"esbuild": "0.14.47",
"eslint": "8.18.0",
"@types/node": "18.0.1",
"@typescript-eslint/eslint-plugin": "5.30.5",
"@typescript-eslint/parser": "5.30.5",
"esbuild": "0.14.48",
"eslint": "8.19.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-simple-import-sort": "7.0.0",

@@ -71,6 +71,6 @@ "husky": "8.0.1",

"mocha-junit-reporter": "2.0.2",
"npm-check-updates": "14.0.1",
"npm-check-updates": "15.0.3",
"prettier": "2.7.1",
"pretty-quick": "3.1.3",
"ts-node": "10.8.1",
"ts-node": "10.8.2",
"typescript": "4.7.4"

@@ -77,0 +77,0 @@ },

@@ -30,6 +30,6 @@ [![Run Tests](https://github.com/SmartBear/one-report-publisher/actions/workflows/test.yaml/badge.svg)](https://github.com/SmartBear/one-report-publisher/actions/workflows/test.yaml)

if: ${{ always() }}
uses: smartbear/one-report-publisher@v0.5.0
uses: smartbear/one-report-publisher@v0.6.0
with:
# Can be omitted if ONE_REPORT_ORGANIZATION is defined
organization: F5222E06-BA05-4C82-949A-2FE537B6F59F
# Can be omitted if ONE_REPORT_PROJECT_ID is defined
project-id: F5222E06-BA05-4C82-949A-2FE537B6F59F
# Can be omitted if ONE_REPORT_TOKEN is defined

@@ -49,3 +49,3 @@ token: ${{ secrets.ONE_REPORT_TOKEN }}

```
npx @smartbear/one-report-publisher@v0.5.0 --help
npx @smartbear/one-report-publisher@v0.6.0 --help

@@ -56,3 +56,3 @@ Usage: one-report-publisher [options]

-u, --url <url> OneReport URL. Defaults to $ONE_REPORT_URL
-o, --organization <id> OneReport organization id. Defaults to $ONE_REPORT_ORGANIZATION
-p, --project-id <id> OneReport project id. Defaults to $ONE_REPORT_PROJECT_ID
-t, --token <token> OneReport token. Defaults to $ONE_REPORT_TOKEN

@@ -69,4 +69,4 @@ -r, --reports <glob...> Glob to the files to publish

```
npx @smartbear/one-report-publisher@0.5.0 \
--organization F5222E06-BA05-4C82-949A-2FE537B6F59F \
npx @smartbear/one-report-publisher@0.6.0 \
--project-id F5222E06-BA05-4C82-949A-2FE537B6F59F \
--token ${ONE_REPORT_TOKEN} \

@@ -85,6 +85,6 @@ --reports ./reports/**/*.{xml,json,ndjson,zip}

command: |
npx @smartbear/one-report-publisher@0.5.0 \
--organization F5222E06-BA05-4C82-949A-2FE537B6F59F \
npx @smartbear/one-report-publisher@0.6.0 \
--project-id F5222E06-BA05-4C82-949A-2FE537B6F59F \
--token ${ONE_REPORT_TOKEN} \
--reports ./reports/**/*.{xml,json,ndjson,zip}
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc