Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1283048ce2 |
@@ -516,14 +516,17 @@ The CLI stores the snapshot at the platform-appropriate data directory via
|
|||||||
`0600`. The key material is stored in cleartext in the JSON; treat this file as
|
`0600`. The key material is stored in cleartext in the JSON; treat this file as
|
||||||
you would treat the password itself. A missing file is reported as "not logged
|
you would treat the password itself. A missing file is reported as "not logged
|
||||||
in"; a file that exists but is corrupt is reported as such, naming the bad
|
in"; a file that exists but is corrupt is reported as such, naming the bad
|
||||||
field. When the server answers a command's request with HTTP 401, because it no
|
field. When the refresh a command starts with gets HTTP 401 from the server,
|
||||||
longer accepts the saved session's token, the command prints one line,
|
because it no longer accepts the saved session's token, the command prints one
|
||||||
`quak: the saved session is no longer valid; run "quak login"`, with no stack
|
line, `quak: the saved session is no longer valid; run "quak login"`, with no
|
||||||
trace. All three exit with status 3, which means the user must run `quak login`
|
stack trace. All three exit with status 3, which means the user must run
|
||||||
again. `quak logout` is the exception: with no file it says there is no session
|
`quak login` again. `quak logout` is the exception: with no file it says there
|
||||||
and exits 0, and it handles a corrupt file or a failed server call as described
|
is no session and exits 0, and it handles a corrupt file or a failed server call
|
||||||
below. `quak backup` meets an expired session on the refresh that starts every
|
as described below. `quak backup` meets an expired session on the refresh that
|
||||||
run, before it touches any file. No command but `quak login` ever prompts.
|
starts every run, before it touches any file. A session that stops working
|
||||||
|
partway through a backup instead fails each remaining file into `failures.json`,
|
||||||
|
so that run exits 1 and the next one stops at its refresh with status 3. No
|
||||||
|
command but `quak login` ever prompts.
|
||||||
|
|
||||||
`quak logout` ends the session on the server, so the token in `session.json`
|
`quak logout` ends the session on the server, so the token in `session.json`
|
||||||
stops working even in a copy of the file, and then deletes the file. If the
|
stops working even in a copy of the file, and then deletes the file. If the
|
||||||
|
|||||||
@@ -230,14 +230,24 @@ describe("session file", () => {
|
|||||||
expect(JSON.parse(readFileSync(path, "utf-8"))).toEqual(snapshot);
|
expect(JSON.parse(readFileSync(path, "utf-8"))).toEqual(snapshot);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("a missing session exits 3 with 'Not logged in'", async () => {
|
it("a missing session exits 3 with 'Not logged in' from every command that needs one", async () => {
|
||||||
const ctx = { ...context(), loadSession };
|
const ctx = { ...context(), loadSession };
|
||||||
|
const dir = join(root, "backup");
|
||||||
expect(await whoamiCommand(ctx)).toBe(3);
|
expect(await whoamiCommand(ctx)).toBe(3);
|
||||||
expect(stderr.text).toBe(
|
expect(await collectionsCommand(ctx, {})).toBe(3);
|
||||||
|
expect(await filesCommand(ctx, { collection: "1" })).toBe(3);
|
||||||
|
expect(await getCommand(ctx, "100", {})).toBe(3);
|
||||||
|
expect(await getThumbCommand(ctx, "100", {})).toBe(3);
|
||||||
|
expect(await backupMetadataCommand(ctx, dir, {})).toBe(3);
|
||||||
|
expect(await backupCommand(ctx, dir, {})).toBe(3);
|
||||||
|
expect(await listMissingThumbnailsCommand(ctx, {})).toBe(3);
|
||||||
|
expect(await fixMissingThumbnailsCommand(ctx, {})).toBe(3);
|
||||||
|
const notLoggedIn =
|
||||||
`Not logged in. Run "quak login" first.\n` +
|
`Not logged in. Run "quak login" first.\n` +
|
||||||
`Session file: ${join(ctx.sessionDir, "session.json")}\n`,
|
`Session file: ${join(ctx.sessionDir, "session.json")}\n`;
|
||||||
);
|
expect(stderr.text).toBe(notLoggedIn.repeat(9));
|
||||||
expect(stdout.text).toBe("");
|
expect(stdout.text).toBe("");
|
||||||
|
expect(existsSync(dir)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("a corrupt session exits 3 and says it is corrupt", async () => {
|
it("a corrupt session exits 3 and says it is corrupt", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user