Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create TOTP node #5901

Merged
merged 10 commits into from
Apr 11, 2023
Merged

feat: Create TOTP node #5901

merged 10 commits into from
Apr 11, 2023

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Apr 4, 2023

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Files matching packages/nodes-base/nodes/**:

  • Added workflow tests for nodes if possible.

Make sure to check off this list before asking for review.

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team node/new Creation of an entirely new node labels Apr 4, 2023
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Patch coverage: 77.41% and project coverage change: +0.01 🎉

Comparison is base (5651a52) 17.55% compared to head (f315962) 17.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5901      +/-   ##
==========================================
+ Coverage   17.55%   17.57%   +0.01%     
==========================================
  Files        2498     2500       +2     
  Lines      114358   114384      +26     
  Branches    17867    17870       +3     
==========================================
+ Hits        20080    20098      +18     
- Misses      93686    93694       +8     
  Partials      592      592              
Impacted Files Coverage Δ
...ages/nodes-base/credentials/TotpApi.credentials.ts 0.00% <0.00%> (ø)
packages/nodes-base/nodes/Totp/Totp.node.ts 91.66% <91.66%> (ø)
packages/editor-ui/src/plugins/icons.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

packages/nodes-base/nodes/Totp/Totp.node.ts Outdated Show resolved Hide resolved
pnpm-lock.yaml Outdated Show resolved Hide resolved
Copy link
Member

@netroy netroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please add some tests for the node ? 🙏🏽

@@ -30,6 +30,24 @@ import path from 'path';
import { tmpdir } from 'os';
import { isEmpty } from 'lodash';

import { FAKE_CREDENTIALS_DATA } from './FakeCredentialsMap';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this draft

packages/nodes-base/nodes/Totp/Totp.node.ts Outdated Show resolved Hide resolved
packages/nodes-base/nodes/Totp/Totp.node.ts Outdated Show resolved Hide resolved
packages/nodes-base/nodes/Totp/Totp.node.ts Outdated Show resolved Hide resolved
Comment on lines +141 to +143
if (!options.algorithm) options.algorithm = 'SHA1';
if (!options.digits) options.digits = 6;
if (!options.period) options.period = 30;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a cleaner way to specify default options? Adding default: { algorithm: 'SHA1', period: 30, digits: 6 } causes the options to start off revealed, which is not what we want, but otherwise options defaults to {}, which is also not what we want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this?

const options = {
	algorithm: 'SHA1',
	digits: 6,
	period: 30,
	...(this.getNodeParameter('options', 0, {}) as IDataObject)),
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I should've been clearer. By "cleaner" I meant to avoid repeating all these defaults that were already specified in the node params above, for maintainability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not that I'm aware of, we could use some const/enum defaultOptions to make it dryer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think the ideal would be for getNodeParameter to return an object with every field set to its default value, so that making it dryer does not introduce too much indirection. Let's ignore for now then.

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@janober
Copy link
Member

janober commented Apr 19, 2023

Got released with [email protected]

sunilrr pushed a commit to fl-g6/qp-n8n that referenced this pull request Apr 24, 2023
* ✨ Create TOTP node

* ♻️ Apply feedback

* ♻️ Recreate `pnpm-lock.yaml`

* ♻️ Apply Giulio's feedback

* 🚧 WIP node tests

* ✅ Finish node test setup

* ⏪ Restore test command

* ⚡ linter fixes, tweaks

* ♻️ Address Michael's feedback

---------

Co-authored-by: Michael Kret <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team node/new Creation of an entirely new node Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants