yuto-yuto 3 years ago
parent cd168a303d
commit 2e1cab23a4
  1. 26
      .vscode/launch.json
  2. 2
      Docker/Dockerfile
  3. 2
      Docker/docker-compose.yml
  4. 6
      Docker/flow/.config.nodes.json
  5. 6
      Docker/flow/.config.nodes.json.backup
  6. 13
      package.json
  7. 13
      test/PasswordGenerator_spec.ts

@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Test",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"sourceMaps": true,
"skipFiles": ["<node_internals>/**"],
"args": [
"-r",
"ts-node/register",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/test/**/*_spec.ts"
],
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceFolder}"
}
]
}

@ -1,7 +1,7 @@
FROM nodered/node-red
# error without this
RUN mkdir -p ./password-generator/node_modules/
# RUN mkdir -p ./password-generator/node_modules/
COPY ../package.json ../package-lock.json ./password-generator/
COPY ../dist ./password-generator/dist

@ -2,7 +2,7 @@ version: "3.7"
services:
nodered:
image: nodered-update-detector
image: nodered-password-generator
ports:
- "1880:1880"
volumes:

@ -397,15 +397,15 @@
"version": "1.0.0",
"local": false,
"nodes": {
"valueChangeDetector": {
"name": "valueChangeDetector",
"passwordGeneratorNode": {
"name": "passwordGeneratorNode",
"types": [
"password-generator"
],
"enabled": true,
"local": false,
"module": "node-red-contrib-password-generator",
"file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/ValueChangeDetectorNode.js"
"file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/PasswordGeneratorNode.js"
}
}
}

@ -397,13 +397,13 @@
"version": "1.0.0",
"local": false,
"nodes": {
"valueChangeDetector": {
"name": "valueChangeDetector",
"passwordGeneratorNode": {
"name": "passwordGeneratorNode",
"types": [],
"enabled": true,
"local": false,
"module": "node-red-contrib-password-generator",
"file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/ValueChangeDetectorNode.js"
"file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/PasswordGeneratorNode123.js"
}
}
}

@ -1,24 +1,24 @@
{
"name": "node-red-contrib-password-generator",
"version": "1.0.0",
"description": "Send message only when the specified key's value changes",
"description": "Generate random password",
"main": "index.js",
"scripts": {
"start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS",
"build": "tsc && cp ./lib/*.html ./dist/lib/",
"build-d": "npm run build && docker build -t nodered-update-detector -f ./Docker/Dockerfile .",
"build-d": "npm run build && docker build -t nodered-password-generator -f ./Docker/Dockerfile .",
"clean": "rm -rf ./dist",
"test": "mocha --recursive --require ts-node/register test/*.ts"
},
"keywords": [
"node-red",
"password-generator",
"update-detector",
"rbe"
"rbe",
"crypto"
],
"node-red": {
"nodes": {
"valueChangeDetector": "./dist/lib/ValueChangeDetectorNode.js"
"passwordGeneratorNode": "./dist/lib/PasswordGeneratorNode.js"
}
},
"author": "yuto-yuto",
@ -32,14 +32,13 @@
"@types/sinon": "^9.0.5",
"chai": "^4.2.0",
"mocha": "^8.1.3",
"node-red": "^1.3.5",
"node-red-node-test-helper": "^0.2.6",
"sinon": "^9.0.3",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
},
"dependencies": {
"fast-deep-equal": "^3.1.3",
"node-red": "^1.3.5",
"yutolity": "^1.1.1"
}
}

@ -1,11 +1,22 @@
import "mocha";
import * as crypto from "crypto";
import { expect } from "chai";
import * as sinon from "sinon";
import { generatePassword } from "../lib/PasswordGenerator";
describe("PasswordGenerator", () => {
it("should return true for the first time", async () => {
const result = await generatePassword(10);
console.log(`before: "${result}"`)
expect(result).to.lengthOf(10);
});
// it.only("should return true for the first time", async () => {
// const testData = Buffer.from([31, 32, 126, 127]);
// sinon.stub(crypto, "randomBytes")
// .callsFake((size: number, cb: (err: Error | null, buf: Buffer) => void) => {
// console.log("HEY")
// cb(null, testData);
// });
// const result = await generatePassword(10);
// expect(result).to.equal(" ~");
// });
});
Loading…
Cancel
Save