Skip to content

Commit

Permalink
Merge pull request #5 from lisb/feature/fix-smoke-testing
Browse files Browse the repository at this point in the history
Fix smoke testing
  • Loading branch information
krdlab authored Apr 16, 2021
2 parents ebb2577 + f8ac71b commit 7fe4e22
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ jobs:
- name: Run smoke tests
timeout-minutes: 2
run: |
touch .credential
echo ${{ secrets.DIRECT_TESTING_USER }} >> .credential
echo ${{ secrets.DIRECT_TESTING_PASSWORD }} >> .credential
node test/login.js < .credential
node test/login.js "${{ secrets.DIRECT_TESTING_USER }}:${{ secrets.DIRECT_TESTING_PASSWORD }}"
node test/smoke.js
- name: Remove credentials
run: rm -f .credential .env
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# misc
.env
storage.local
14 changes: 12 additions & 2 deletions test/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@

const direct = require("../lib/direct-node.min.js").DirectAPI;
const fs = require("fs");
const path = require("path");
const url = require("url");

const endpoint = "wss://api.direct4b.com/albero-app-server/api";
const dotenv = path.join(process.cwd(), ".env");

const args = process.argv.slice(2);
if (args.length === 0 || !args[0].includes(':')) {
console.error('"id:password" was not found in arguments');
process.exit(1);
}
const account = args[0];

const client = direct.getInstance();

client.setOptions({
host: url.parse(endpoint).host,
endpoint: endpoint
endpoint: endpoint,
account
});

client.on("access_token_changed", token => {
fs.writeFileSync(".env", `HUBOT_DIRECT_TOKEN=${token}`);
fs.writeFileSync(dotenv, `HUBOT_DIRECT_TOKEN=${token}`);
console.log("logged in.");
process.exit();
});
Expand Down
4 changes: 3 additions & 1 deletion test/smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

const direct = require("../lib/direct-node.min.js").DirectAPI;
const fs = require("fs");
const path = require("path");
const url = require("url");

const endpoint = "wss://api.direct4b.com/albero-app-server/api";
const dotenv = path.join(process.cwd(), ".env");
const accessToken = fs
.readFileSync(".env")
.readFileSync(dotenv)
.toString()
.replace("HUBOT_DIRECT_TOKEN=", "");

Expand Down

0 comments on commit 7fe4e22

Please sign in to comment.