Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function getLair() {
return processResponseFromClient(response);
}

function getLairUrl() {
return utils.getLairUrl();
}

function getWorkspace() {
let lair = getLair();
let workspaceId = lair.workspace_id;
Expand All @@ -58,4 +62,4 @@ function getUserByApplicationKey(applicationKey){
}


module.exports = {getProcessDetailExpandedData, getProcess, getEvent, getLairTrigger, getLair, getWorkspace, getUserByApplicationKey};
module.exports = {getProcessDetailExpandedData, getProcess, getEvent, getLairTrigger, getLair, getLairUrl, getWorkspace, getUserByApplicationKey};
10 changes: 9 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ function getApplicationKey(){
return process.env.WAYSCRIPT_EXECUTION_USER_APPLICATION_KEY;
}

function getLairUrl() {
return process.env.WAYSCRIPT_LAIR_URL;
}

function getProcessExecutionUserRefreshToken() {
return process.env.WAYSCRIPT_EXECUTION_USER_REFRESH_TOKEN || "";
}

class WayScriptClient {
constructor() {
this.user_auth_token = getProcessExecutionUserToken();
Expand Down Expand Up @@ -107,4 +115,4 @@ class WayScriptClient {
}
}

module.exports = {getProcessExecutionUserToken, getProcessUUID, getApplicationKey, WayScriptClient};
module.exports = {getProcessExecutionUserToken, getProcessUUID, getApplicationKey, getLairUrl, getProcessExecutionUserRefreshToken, WayScriptClient};
26 changes: 26 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ test('Build Workspace Endpoint URL', () => {
expect(wayscriptClient.buildURLEndpoint("workspaces","detail",{"id":id})).toBe("https://api.wayscript.com/workspaces/d1e498e4-2f32-4e5c-803e-d5fe1e2b89fe");
});

describe('Environment Variables', () => {
const OLD_ENV = process.env;

beforeEach(() => {
jest.resetModules();
process.env = { ...OLD_ENV };
});

afterAll(() => {
process.env = OLD_ENV;
});

test('Get Environment Variables', () => {
process.env.WAYSCRIPT_EXECUTION_USER_TOKEN = "user_token";
process.env.WAYSCRIPT_EXECUTION_USER_REFRESH_TOKEN = "user_refresh_token";
process.env.WAYSCRIPT_EXECUTION_USER_APPLICATION_KEY = "user_application_key";
process.env.WAYSCRIPT_LAIR_URL = "https://some-lair-url.wayscript.com/";
process.env.WS_PROCESS_ID = "process_id";

expect(utils.getProcessExecutionUserToken()).toBe("user_token");
expect(utils.getProcessExecutionUserRefreshToken()).toBe("user_refresh_token");
expect(utils.getApplicationKey()).toBe("user_application_key");
expect(utils.getLairUrl()).toBe("https://some-lair-url.wayscript.com/");
expect(utils.getProcessUUID()).toBe("process_id");
})
})

test.skip('Get Process Data From Response From Request', () => {

Expand Down