From da0b00b7c804b406e82204f561c149805fd1d0da Mon Sep 17 00:00:00 2001 From: "sho.kuroda" Date: Mon, 23 Mar 2020 23:12:43 +0900 Subject: [PATCH 1/4] test: Use an absolute path to read/write file --- test/login.js | 4 +++- test/smoke.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/login.js b/test/login.js index a7cd181..e0e4b2d 100644 --- a/test/login.js +++ b/test/login.js @@ -5,9 +5,11 @@ 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 client = direct.getInstance(); @@ -17,7 +19,7 @@ client.setOptions({ }); 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(); }); diff --git a/test/smoke.js b/test/smoke.js index d035e63..aba67c0 100644 --- a/test/smoke.js +++ b/test/smoke.js @@ -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=", ""); From d71a5d7d90e7eb6877c18d663858fa95f6c84b14 Mon Sep 17 00:00:00 2001 From: "sho.kuroda" Date: Mon, 23 Mar 2020 23:21:40 +0900 Subject: [PATCH 2/4] test: Always run 'remove credentials' task --- .github/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index eff7a41..9a76a15 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -26,4 +26,5 @@ jobs: node test/smoke.js - name: Remove credentials + if: always() run: rm -f .credential .env From 956305e6950645e19c40a870904e98b2ba00b106 Mon Sep 17 00:00:00 2001 From: "sho.kuroda" Date: Fri, 16 Apr 2021 15:06:14 +0900 Subject: [PATCH 3/4] fix: Use 'account' option --- .github/workflows/testing.yml | 9 +-------- test/login.js | 10 +++++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9a76a15..36c8715 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,12 +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 - if: always() - run: rm -f .credential .env diff --git a/test/login.js b/test/login.js index e0e4b2d..0ce09fa 100644 --- a/test/login.js +++ b/test/login.js @@ -11,11 +11,19 @@ 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 => { From f8ac71bc7ebe6d5bb07b471971005e54e05ef4d5 Mon Sep 17 00:00:00 2001 From: "sho.kuroda" Date: Fri, 16 Apr 2021 15:58:57 +0900 Subject: [PATCH 4/4] chore: update .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 123ae94..973c917 100644 --- a/.gitignore +++ b/.gitignore @@ -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