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

Tests. #21

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Tests. #21

wants to merge 4 commits into from

Conversation

gbminarelli
Copy link
Collaborator

@gbminarelli gbminarelli commented May 3, 2018

Added Tests:

Regression.

A basic regression test on the front. Run regressionTest() anywhere on dir.html to check if the current version is breaking decryption of older files. For now, I'm just logging a success message when the decrypted blob's content equals the expected value of an encrypted control file (regression-control.txt).

Had to refactor dir.js and cipher.js a tiny bit. Also, .gitignore is now 'unignoring' the folder holding the test's control file (cc8).

Edit: I also had to add a trigger on handleFileDownload() to simulate a click on the listed test file. I know this is not ideal (test harnessing?), but this is the only way I could think of to go through every step (function call) a user would go on a traditional upload-encrypt-decrypt-download use case cycle.

Update (May. 04):

Error on fail. Update feedback.

Now the regression test throws and error on fail instead of logging a message when it succeeds and a success message when it succeeds.

Fix page reload.

We need to force reload the page in order to support consecutive tests, since the page won't refresh itself when the URL's path is not updated (in this case, /dir/data/cc8/tluICx+fpoDNb+DsLMquWl+aai5sVg). After the first test (from whatever secret folder on dir.html), only the URL's hash is updated (with the test file's key), hence the need to force a page reload.

I also had to set a delay for the page reload, since it seems that without it the page is reloaded before the URL is updated (which is kinda weird to me, I assumed a synchronous sequence of operations was happening here).

API tests.

We now have tests for the following operations:

  • Make Folder: GET /mkdir.
  • Upload File: POST /secret/folder.
  • List Files: GET /ls.
  • Delete File: DELETE /secret/folder/file.

Notes:

  • All the API tests were set on a single file (api.js).
  • For the Upload File operation test, I'm using the same test file used on the regression test (regression-control.txt).
  • All the other file operation tests are based on the encrypted copy of regression-control.txt (which we get after the Upload File operation).

@gbminarelli gbminarelli requested a review from countable May 3, 2018 22:15
@gbminarelli gbminarelli changed the title Add regression test. Add ~regression~ tests. May 4, 2018
@gbminarelli gbminarelli changed the title Add ~regression~ tests. Add tests. May 4, 2018
@gbminarelli gbminarelli changed the title Add tests. Tests. May 5, 2018
test/api.js Show resolved Hide resolved
test/api.js Show resolved Hide resolved
test/api.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants