Commit Graph

262 Commits

Author SHA1 Message Date
Joe Previte
f3c4dcd074
feat(test): try calling .dispose() x2 in emitter 2021-07-02 14:27:12 -07:00
Joe Previte
c0e123a801
fix(http): escape req.query.to in replaceTemplates 2021-07-01 10:43:37 -07:00
Joe Previte
2092f82270
fixup! fix: escape error.message on login failure 2021-07-01 10:43:37 -07:00
Joe Previte
c505fc45a8
feat: add escapeHtml function
This can be used to escape any special characters in a string with HTML before
sending from the server back to the client. This is important to prevent a
cross-site scripting attack.
2021-07-01 10:43:36 -07:00
Joe Previte
7f12fab3ca
fix(isHashMatch): check that hash starts with $
Previously, we used argon2 to verify the hash with the password.

If the hash didn't start with a $, then it would enter the catch block.

Now we check the hash before trying to verify it and we also throw an Error if
the verify fails.

This makes the isHashMatch function more robust.
2021-06-30 15:00:21 -07:00
Asher
2238d7391e
Fix occasional logout failure
It seems a dialog sometimes appears asking if you want to lose
changes (even though we have no changes; it seems based on timers in
some way). Playwright defaults to dismissing them (so quickly you might
not even see them) so accepting instead fixes navigation to the logout
page getting canceled.
2021-06-29 12:06:48 -05:00
Asher
43c6ffcb8f
Remove login steps from logout test
I figure login is already tested so we can skip this and just use the
cookie.
2021-06-29 12:06:47 -05:00
Asher
49c7cc6e8a
Retain failed e2e videos only 2021-06-29 12:06:46 -05:00
Asher
f2fa7701a9
Centralize credential handling
My thinking is that this may reduce the cognitive overhead for
developers writing new test suites.

This also allows us to perform different setup steps (like ensuring the
editor is visible when authenticated).
2021-06-29 12:06:45 -05:00
Asher
da4de439e0
Spawn a code-server instance for each test suite
This uses the current dev build by default but can be overidden with
CODE_SERVER_TEST_ENTRY (for example to test a release or some other
version).

Each instance has a separate state directory. This should make
parallelization work.

This also means you are no longer required to specify the password and
address yourself (or the extension directory once we add a test
extension). `yarn test:e2e` should just work as-is.

Lastly, it means the tests are no longer subject to yarn watch randomly
restarting.
2021-06-29 12:06:38 -05:00
Asher
49c44818d9
Move onLine to utilities
This way it can be used by the tests when spawning code-server on a
random port to look for the address.
2021-06-29 12:04:31 -05:00
Asher
add55ecd62
Import utils as a group in tests
This should simplify testing new utils a bit.
2021-06-29 12:03:38 -05:00
Asher
ba0364a522
Run each e2e test in a new workspace
The workspaces also have settings to prevent the welcome page from
appearing.
2021-06-29 12:03:37 -05:00
Joe Previte
6e1455da88
feat: add custom codecov 2021-06-28 11:41:48 -07:00
Joe Previte
b597519ab5
feat(test): add tests for src/browser/login 2021-06-28 11:41:48 -07:00
Joe Previte
02b9489489
refactor: add func getNlsConfiguration & tests
This PR refactors part of vscode.ts and adds a function to get the NLS
Configuration.

This makes the code more readable and easier to test.

And it adds multiple tests for this part of the codebase.
2021-06-23 13:42:06 -07:00
Max Schmitt
dbb34ad710 chore: upgrade to Playwright 1.12 with its new test-runner 2021-06-10 15:09:38 +02:00
Joe Previte
1e55a648a5
feat: check for empty str in isHashMatch 2021-06-08 15:10:59 -07:00
Joe Previte
3b50bfc17d
fix: sanitize password and cookie key 2021-06-08 14:33:17 -07:00
Joe Previte
8c2bb61af9
refactor: parse options with multiple = in cli
There was a case with the hashed-password which had multiple equal signs in the
value and it wasn't being parsed correctly. This uses a new function and adds a
few tests.
2021-06-08 14:33:17 -07:00
Joe Previte
531b7c0c25
feat: add splitOnFirstEquals function 2021-06-08 14:33:16 -07:00
Joe Previte
517aaf71c5
docs: update FAQ with new hashing instructions 2021-06-08 14:33:16 -07:00
Joe Previte
6020480b30
feat: add isCookieValid function and tests 2021-06-08 14:33:16 -07:00
Joe Previte
a14ea39c4a
feat: add handlePasswordValidation + tests 2021-06-08 14:33:15 -07:00
Joe Previte
7ff4117531
feat: add getPasswordMethod & test for it 2021-06-08 14:33:15 -07:00
Joe Previte
ffa5c16e51
feat: update cli and test for hashed-password 2021-06-08 14:33:15 -07:00
Joe Previte
788b958e20
refactor: update hash fn in test config 2021-06-08 14:33:14 -07:00
Joe Previte
fd3cb6cfa0
refactor: update unit tests for hash fns
Since the hash and isHashMatch are now async, I had to update the tests
accordingly. Now everything is working.
2021-06-08 14:33:13 -07:00
Joe Previte
51f8341959
chore: update to argon2 in test 2021-06-08 14:33:13 -07:00
Joe Previte
fc3326f1f2
feat: add tests using real hashes 2021-06-08 14:33:12 -07:00
Joe Previte
aaf044728f
refactor: add functions to check hash password 2021-06-08 14:33:12 -07:00
Joe Previte
f35120c0a3
feat: add unit test for hash function 2021-06-08 14:33:12 -07:00
Joe Previte
17be8c5cd3
refactor: use bcrypt in e2e setup 2021-06-08 14:33:12 -07:00
dependabot[bot]
0832df1a3f
chore(deps): bump ws from 7.4.2 to 7.4.6 in /test (#3510)
Bumps [ws](https://github.com/websockets/ws) from 7.4.2 to 7.4.6.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/7.4.2...7.4.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-31 20:12:53 +05:30
dependabot[bot]
20874c1833
chore(deps): bump browserslist from 4.16.4 to 4.16.6 in /test
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.4 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.16.4...4.16.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 21:28:37 +00:00
Joe Previte
46fe77d464
chore: update CHANGELOG 2021-05-13 12:10:22 -07:00
Joe Previte
2a657ab930
feat: add tests for getEnvPaths 2021-05-13 12:10:21 -07:00
Akash Satheesan
adc9b57080
chore: reformat with new prettier 2021-05-12 01:14:04 +05:30
dependabot[bot]
65c2510faa
chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 in /test (#3312)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-08 00:04:25 +05:30
Asher
4f320ad3e0
Merge pull request #3297 from code-asher/test-static 2021-05-06 18:24:44 -05:00
Asher
e8443e2602
Fix helpers not working in e2e tests
It errors that jest is not defined so put it behind a function instead
of immediately creating the mock (this is probably a better pattern
anyway).

The constant tests had to be reworked a little. Since the logger mock is
hoisted it runs before createLoggerMock is imported. I moved it into a
beforeAll which means the require call also needed to be moved
there (since we need to mock the logger before requiring the constants
or it'll pull the non-mocked logger).

This means getPackageJson needs to be a let and assigned afterward. To
avoid having to define a type for getPackageJson I just added a let var
set to the type of the imported constants file and modified the other
areas to use the same paradigm.

I also replaced some hardcoded strings with the mocked package.json
object.
2021-05-06 15:01:35 -05:00
dependabot[bot]
14dbd16a7a
chore(deps): bump lodash from 4.17.20 to 4.17.21 in /test (#3300)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-07 01:30:47 +05:30
Asher
ad4a70c684
Use warn log level for integration tests
Just to limit all the noise from code-server's startup output.
2021-05-06 14:27:16 -05:00
Asher
4925e97080
Add static route tests 2021-05-06 14:27:11 -05:00
Asher
1789cd1bcb
Move temp test dirs under a tests sub-directory
This is to match the other tests that create temp directories. It also
lets you clean up test temp directories all at once separately from
other non-test temporary directories.
2021-05-06 14:25:51 -05:00
Asher
52cf2fcf29
Move tmpdir test helper to test helpers file 2021-05-06 14:25:50 -05:00
Asher
0e4672f6b9
Move health route tests to routes directory 2021-05-06 14:25:49 -05:00
Joe Previte
cb5ab48d48
fix: coveragePathIgnorePatterns to /out
We were accidentally ignoring `node/routes` because we had "out"
instead of "/out" in `coveragePathIgnorePatterns` which caused
us to not collect coverage for those files. Now we do.
2021-05-06 11:53:17 -07:00
Joe Previte
027106a5e1
feat(testing): add test for constants "version" and commit 2021-05-05 15:34:48 -07:00
Asher
a882be5748
Refactor integration tests to use main entry point 2021-05-05 12:24:41 -05:00