From 8e76aa1d75aebdadd0451d2e57c9bb65d1e75b9a Mon Sep 17 00:00:00 2001 From: "Theodore R. Smith" Date: Sun, 27 Dec 2020 09:13:11 -0600 Subject: (#3520) [cli] Hardened `auth add`: No longer fails with extraneous characters. **The Solution:** I have hardened `auth add` by stripping out everything from the third '/' to the end of the instance URL. **The Problem:** When adding an authorization for the peertube-cli, before this commit you could not have anything after the domain_name:port. For instance, if there was a trailing / in your instance URL, before this commit it will always fail with expected 200 "OK", got 404 "Not Found". It took me over 20 minutes to figure out that this was the problem. See Issue #3091. --- server/tests/cli/peertube.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 348438533..fcf7e2e2e 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -66,6 +66,18 @@ describe('Test CLI wrapper', function () { await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`) }) + it('Should not fail to add a user if there is a slash at the end of the instance URL', async function () { + this.timeout(60000) + + const env = getEnvCli(server) + let fullServerURL + fullServerURL = server.url + '/' + await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) + + fullServerURL = server.url + '/asdfasdf' + await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) + }) + it('Should default to this user', async function () { this.timeout(60000) -- cgit v1.2.3