Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Frontend tests #193

Merged
merged 18 commits into from
Jul 17, 2017
Merged

Frontend tests #193

merged 18 commits into from
Jul 17, 2017

Conversation

abhinadduri
Copy link
Collaborator

@abhinadduri abhinadduri commented Jul 13, 2017

Fixes #181

package.json Outdated
@@ -52,6 +52,7 @@
"lint:js": "eslint .",
"start": "node server/server",
"test": "mocha test/unit && mocha test/server",
"test-browser": "watchify test/frontend/frontend.bundle.js -o test/frontend/bundle.js -d",
Copy link
Collaborator

Choose a reason for hiding this comment

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

if "test/frontend/bundle.js" is compiled/browserified, we may want to add it to .gitignore and nuke the file below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ahh good idea. Did not mean to push that.

constructor(name, data, opt) {
super(data, opt);
this.name = name;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indenting looks weird in this file (4 space indent). We may want to confirm that ESLint and prettier are linting these files. I would have almost expected CircleCI linting to fail on these.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the line in package.json that you may want to tweak:

"format": "prettier '{frontend/src/,scripts/,server/,test/}*.js' 'public/*.css' --single-quote --write",

Instead of "test/", we'll need "test/**/" due to the nested files in the test directory.
Although, I think if I currently run npm run format on the codebase it may break linting, so I'll shut up now.

})
})

it('Should catch tampered checksums', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "tampered" isn't the best word for this. It took me a while to understand what you meant since tampering can happen at other times besides creation. Phony, bogus, or fraudulent better imply it's the creator that's being a jerk.

{
name: 'AES-GCM',
iv: hexToArray(encryptedIV),
additionalData: fileHash,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment here, this is the meat of this whole test, lets make it obvious that fileHash is the phony checksum

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Gotcha, will do.

}),
new Promise((resolve, reject) => {
resolve(hexToArray(fdata.aad));
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

For these two promises, I don't think you need a Promise wrapper since you're doing a Promise.all() above. IIRC, you can just return fdata.filename and hexToArray(fdata.aad) and it should still work the same.

Copy link
Collaborator Author

@abhinadduri abhinadduri Jul 17, 2017

Choose a reason for hiding this comment

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

Fixed.

}),
new Promise((resolve, reject) => {
resolve(fname);
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. I think you can just do return Promise.all([decrypted, fname]); or possibly even Promise.resolve([decrypted, fname]);.

Copy link
Collaborator Author

@abhinadduri abhinadduri Jul 17, 2017

Choose a reason for hiding this comment

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

Fixed.

circle.yml Outdated
pre:
- npm i -g get-firefox
- get-firefox --platform linux --extract --target /home/ubuntu/send
- npm i -g geckodriver
Copy link
Collaborator

Choose a reason for hiding this comment

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

I bet you can add this global install to the line 10 npm i -g get-firefox geckodriver and install them both at the same time.

Not sure if we'd want to add these as devDependencies if we'd ever need to run them locally. 🤷‍♀️

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dannycoates What are your thoughts on adding these as devDependencies?

</script>

<script>
</script>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Probably don't need the empty <script></script> tag here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@abhinadduri abhinadduri merged commit 4122f4d into master Jul 17, 2017
@dannycoates dannycoates deleted the frontend_tests branch July 31, 2017 21:39
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants