diff --git a/AGENTS.md b/AGENTS.md index ec291df..b01e6de 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,9 +5,9 @@ in this repository. `CLAUDE.md` is a symlink to it. `README.md` is for the person *using* the toolkit, who is not technical and runs it from Goose or Claude Desktop. Keep it in plain words: what to ask for, -what is safe, how to set up once using what AAIF already has. Engine detail, -first-time setup (creating the Google client, Slack app and Luma key), adding -the next person and the standalone-zip list belong in `MAINTAINING.md`. `CONTRIBUTING.md` covers skill +what is safe, how to set up once, including creating their own Google connection +file and Slack and Luma keys. Engine detail, first-time setup (creating the Slack +app), adding the next person and the standalone-zip list belong in `MAINTAINING.md`. `CONTRIBUTING.md` covers skill authoring; `DESIGN.md` covers how anything this repo renders for a human is styled. This file is what those don't say. diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ec486..8cb799a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,11 @@ plugin version is mirrored in root `plugin.json` and `.claude-plugin/plugin.json detail and the standalone-zip list moved to `MAINTAINING.md` (`check_portable_skills.py` reads it there). - **Setup instructions for both kinds of setup.** `MAINTAINING.md` walks the - first person through creating the Google client, Slack app and Luma key, and - lists what to do for each person after that. The README takes that next - person through everything else without a helper. `aaif-check-setup` now + first person through creating the Slack app, and lists what to do for each + person after that. The README takes that next person through everything else + without a helper, including creating their own Google connection file and + Slack and Luma keys, because operators can be in different organizations and a + Slack user token acts as whoever generated it. `aaif-check-setup` now reports a missing Google connection file instead of recommending a sign-in that cannot work. - **`aaif-check-setup`** — "check my setup" runs a read-only ✅/❌ check of diff --git a/MAINTAINING.md b/MAINTAINING.md index 510ea24..8ce1fa2 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -3,7 +3,7 @@ [README.md](README.md) is for the person who *uses* the toolkit, written for someone who is not technical. This file is for whoever keeps it running: how it is built, what each engine does, how Google access is wired, and the setup that -happens once per organization, before anyone can follow the README. +happens once, before anyone can follow the README. Packaged as a portable [Agent Plugin](https://agent-plugins.org) with plain [Agent Skills](https://agentskills.io) so the same checkout works across Goose, @@ -16,47 +16,19 @@ manifest is the root `plugin.json`. See [Using in other tools](#using-in-other-t ## First-time setup -Do this once per organization. It creates the three things every later operator -reuses: a Google connection file, a Slack token and a Luma key. Keep them in a -password manager, then follow the README's *Set up once* for yourself. - -### Google connection file - -Use the Google account that owns the toolkit. With `gcloud` installed, -`gws auth setup` can help with parts 1 and 2. It points you at External, so -still make the choice in part 3. - -1. [Create a Google Cloud project](https://console.cloud.google.com/projectcreate) - named `aaif-toolkit`. -2. [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com,sheets.googleapis.com,docs.googleapis.com,slides.googleapis.com,forms.googleapis.com): - Drive, Sheets, Docs, Slides and Forms. -3. [Set up the consent screen](https://console.cloud.google.com/auth/overview) - with the app name `AAIF Toolkit`. Choose **Internal** if every operator's - account is in this Workspace. Otherwise choose **External**, leave it in - testing mode, and add each operator under - [Audience → Test users](https://console.cloud.google.com/auth/audience). - Google [expires an External testing app's refresh tokens after 7 - days](https://developers.google.com/identity/protocols/oauth2), so those - operators sign in again weekly. -4. [Create a client](https://console.cloud.google.com/auth/clients) of type - **Desktop app** and download its JSON. That file is the connection file. Keep - its name, because the README's move command looks for `client_secret*.json`. - -| Google says | Cause | -|---|---| -| Access blocked | The account is not a test user on an External app | -| `redirect_uri_mismatch` | The client is not a **Desktop app**; make a new one | -| `accessNotConfigured` | An API in part 2 is not enabled | +Do this once. It creates the Slack app every operator gets their token from, and +checks the Luma calendar is ready. Then follow the README's *Set up once* for +yourself. Each person creates their own Google connection file and their own +Slack and Luma keys there. -### Slack token +### Slack app -It is a **user** token (`xoxp-`), not a bot token, because the creator of a +Each operator's token is a **user** token (`xoxp-`), not a bot token, because the creator of a channel joins it and a bot would sit in every chapter room. So the token acts as whoever installs the app: it sees what they see, and every room it creates adds them. Its `search:read` scope also lets anyone holding it search that person's DMs and private rooms, and its `chat:write` scope lets them post as that person. -So install it from a dedicated account with no personal DMs or private rooms if -you can. +So each person generates their own and never shares it. 1. Open [Slack's app page](https://api.slack.com/apps?new_app=1), choose **From a manifest**, and pick the community workspace. @@ -85,17 +57,15 @@ you can. ``` 3. **Install to Workspace**, then **Allow**. A workspace may need an admin to - approve it first. -4. Under **OAuth & Permissions**, copy the **User OAuth Token**. + approve it first, under **Requested apps**. A custom app has no marketplace + listing, so its marketplace link shows an error. +4. Under **OAuth & Permissions**, copy your **User OAuth Token**. `channels:join` is deliberately absent: Slack offers it to bot tokens only, and a user token joins with `channels:write`. The write token runs both the audits and the write steps; a token stored as `aaif-slack-read-token` alone runs the audits but not provision, invite or the directory posts. -**Everyone shares this one token.** The next person gets it from an admin and -creates nothing. - **A personal, read-only alternative is the Slack CLI's own login.** Install the [Slack CLI](https://docs.slack.dev/tools/slack-cli/), run `slack login`, paste the `/slackauthticket ...` line it prints into any conversation in the workspace, @@ -106,47 +76,68 @@ audits but not the activity or spam audits, or any write step. It has expired on us before, and `aaif-check-setup` does not look there, so its Slack line stays ⚪ even when this token works. To replace an expired one, run `slack login` again. -### Luma key +### Luma calendar -The calendar needs Luma Plus, and keys are per calendar. In -[Luma](https://luma.com/home/calendars), open the calendar, then **Settings → -Developer → API Keys → Create**. Copy the key straight away, because Luma shows -it only once. +The calendar needs Luma Plus, and keys are per calendar. Each person creates their +own under **Settings → Developer → API Keys**. ## Adding the next person The README's *Set up once* is written for this person, who doesn't need to be -technical. The request text in its step 3 is public, so a request proves nothing. +technical. The request text in its step 5 is public, so a request proves nothing. When you get one: 1. **Confirm who is asking**, through a channel you already know, and that AAIF has approved them as an operator. 2. **Share the Chapters folder and the Community Intake Ops sheet** with their - Google address, as an editor. -3. **External consent screen only:** add them as a test user. -4. **Send the connection file, Slack token and Luma key** through a password - manager or another private channel, never the assistant chat. Leave out - whatever they won't use. + Google address, as an editor. Across organizations, have them open both links, + because Workspace settings on either side can block the share. +3. **Add them as a collaborator on the Slack app**: on + [Slack's app page](https://api.slack.com/apps), choose the app, then + **Collaborators**. They must already be in the workspace. A collaborator can + change the app's settings, so add only approved operators. +4. **Add them to the private organizer rooms**, if they'll run the sync or the + Slack audits, and add an `Ops staff email` row for them on the `Slack Config` + tab so later provisioning runs seed them into new rooms. A user token only + sees private rooms its owner is in. Without this, the setup check shows ✅ but + those rooms read as missing: the audit aborts, invites skip them, and + provisioning plans creates that fail with `name_taken`. +5. **Add them as an admin of the Luma calendar.** + +Leave out whatever they won't use. They can then finish alone. `aaif-check-setup` ("check my setup") tells them what is still missing. ## Removing a person -Everyone shares the same token and key, so the person keeps working access until -you replace them: - -1. Remove their Drive shares and, on an External consent screen, their test user. -2. Under the Slack app's **OAuth & Permissions**, revoke the token and reinstall - the app. In Luma, delete the key and create a new one. -3. Send the new token and key to everyone who remains. They update the same - Keychain items. +1. Remove their Drive shares. +2. Remove them from the Slack app's **Collaborators**, then end their token. It + stays live until someone does, because only they hold it: + - Ask them to revoke it, if you trust them to. + - If they're leaving the workspace, removing them ends it. + - Otherwise revoke all of the app's tokens on the app's settings page. Every + operator then creates a new one (README step 5). +3. Remove their `Ops staff email` row and take them out of the private organizer + rooms. +4. Remove them from the Luma calendar and delete the key named after them under + **Settings → Developer → API Keys**. + +Also replace any token or key they received from someone else. A token that was +ever passed around still acts as whoever created it. ## What setup relies on - **`gws` must be installed before the assistant app opens**, or its shell will not see the binary (`aaif-check-setup` says "installed but this app cannot see it"). +- **Each person creates their own connection file** because an Internal client + only works inside one organization, and an External one in testing mode needs + every user added and + [expires refresh tokens after 7 days](https://developers.google.com/identity/protocols/oauth2). + With `gcloud` installed, `gws auth setup` can help with the project and + services, but it points at External. The README's move command looks for + `client_secret*.json`, so the file keeps its downloaded name. - **The connection file lives at `~/.config/gws/client_secret.json`.** Without it and without a sign-in, a Drive call answers 401 on a clean machine, and "insufficient authentication scopes" where gcloud credentials exist. Both look diff --git a/README.md b/README.md index e53e4b4..23a1075 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,9 @@ message about a sign-in, token, key or missing tool. ## Set up once -AAIF's Google connection, Slack app and Luma key already exist, so you only -connect to them. This takes about 20 minutes and you don't need to be technical. -If nobody at your organization has set the toolkit up yet, start with +This takes about 30 minutes and you don't need to be technical. You create your +own Google connection and your own Slack and Luma keys. AAIF's Slack app already +exists. If nobody has set it up yet, start with [first-time setup](MAINTAINING.md#first-time-setup). To write posts, bios, invites and recaps, you only need steps 1 and 2. @@ -136,18 +136,24 @@ toolkit updates itself from then on. click **Sync**. 4. Under **Discover**, find **aaif-events** and click **Add**. -### 3. Ask AAIF for your access - -Only AAIF can give you these, and you only ask once. Send this to an AAIF admin, -outside the assistant chat: - -> I'm setting up the AAIF toolkit. My Google address is ___. Please send me the -> Google connection file, the Slack token and the Luma key privately, and give -> me edit access to the Chapters folder and the Community Intake Ops sheet. - -Leave out Slack or Luma if you won't use them. You need the Slack token to run -the sync, the Slack audit or the community update. Without a Luma key, the -toolkit gives you event-page text to paste into Luma by hand. +### 3. Create your Google connection file + +Sign in to Google with your AAIF account first. Each person makes their own file, +because it can be limited to one organization. + +1. [Create a project](https://console.cloud.google.com/projectcreate) named + `aaif-toolkit`. It's free. If Google won't let you, ask your organization's + Google admin to allow it. +2. [Turn on the Google services](https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com,sheets.googleapis.com,docs.googleapis.com,slides.googleapis.com,forms.googleapis.com) + the toolkit uses. Check that `aaif-toolkit` is the selected project. +3. [Set up the sign-in screen](https://console.cloud.google.com/auth/overview): + name it `AAIF Toolkit`, use your own email address, and choose **Internal**. + If Internal isn't offered, choose **External** and add yourself as a test user + on the [Audience page](https://console.cloud.google.com/auth/audience). With + External, Google asks you to sign in again about every 7 days. +4. [Create a client](https://console.cloud.google.com/auth/clients), choose + **Desktop app**, then **Download JSON**. Leave the file in Downloads and don't + rename it. Keep it private. ### 4. Connect Google @@ -163,9 +169,8 @@ by a third party, not by Google or AAIF. If Terminal says `command not found: brew`, go to [brew.sh](https://brew.sh), paste the line on that page into Terminal, and follow the "Next steps" it prints at the end. Then run the line above again. -2. Take the Google connection file only from the admin you asked in step 3, and - save it to your **Downloads** folder without renaming it. Then run this in - Terminal: +2. Move your Google connection file into place by running this in Terminal. Only + use a file you downloaded yourself in step 3, never one someone sends you. ```bash mkdir -p ~/.config/gws && mv ~/Downloads/client_secret*.json ~/.config/gws/client_secret.json && chmod 600 ~/.config/gws/client_secret.json && echo Done @@ -179,16 +184,49 @@ by a third party, not by Google or AAIF. 3. Quit your assistant completely (⌘-Q), open it again, and ask it to *"check my setup and sign me in to Google"*. A browser window opens. Sign in with your AAIF Google account. If Google warns that the app isn't verified, click - **Advanced**, then continue. The screen must name **AAIF Toolkit**. If it - names anything else, stop and tell an AAIF admin. Otherwise, allow everything - it asks for. + **Advanced**, then continue. The screen must name **AAIF Toolkit**, the name + you gave it in step 3. If it names anything else, stop and ask an AAIF admin. + Otherwise, allow everything it asks for. If the check then says this account + can't open the Community Intake sheet, that's expected until you finish step 5, + so don't sign in again. Only approve a Google sign-in that you started from your assistant, whoever sends you a link. -### 5. Save your Slack and Luma keys +### 5. Get your access and create your keys + +Only AAIF can give you access, and you only ask once. Send this to an AAIF admin: + +> I'm setting up the AAIF toolkit. My Google address is ___. Please give me edit +> access to the Chapters folder and the Community Intake Ops sheet, add me as a +> collaborator on the AAIF Slack app and to the private organizer rooms, and give +> me admin access to the AAIF Luma calendar. + +Leave out Slack or Luma if you won't use them. You need a Slack token to run the +sync, the Slack audit or the community update. Without a Luma key, the toolkit +gives you event-page text to paste into Luma by hand. -Save each key in your Mac's Keychain, *not* in the assistant chat, because the +**Create your Slack token.** It acts as you and can read what you can, including +your DMs, so keep it to yourself. + +1. Open [Slack's app page](https://api.slack.com/apps) and choose the AAIF app. +2. Open **OAuth & Permissions**, click **Install to Workspace** or **Reinstall to + Workspace**, then **Allow**. +3. Copy the **User OAuth Token**. It starts with `xoxp-`. + +Your token only sees private rooms you're in. If the sync or a Slack audit says +organizer rooms are missing, don't approve creating them. Ask an AAIF admin to +add you to those rooms, then run it again. + +**Create your Luma key.** + +1. On your [calendars page](https://luma.com/home/calendars), open the AAIF + calendar. +2. Open **Settings → Developer**. Under **API Keys**, click **Create** and name it + after yourself. +3. Copy the key straight away, because Luma shows it only once. + +**Save each key** in your Mac's Keychain, *not* in the assistant chat, because the chat keeps everything you type. 1. Open **Keychain Access**. Press ⌘-Space and type "Keychain Access". @@ -203,6 +241,10 @@ chat keeps everything you type. 4. Click **Add**. The first time a job uses the key, your Mac asks whether to allow it. Click **Always Allow**. +To replace a key later, don't add a second item with the same name. Double-click +the existing item in Keychain Access, tick **Show password**, paste the new key +and click **Save Changes**. + ### 6. Check it Ask your assistant to **"check my setup"**. Each ❌ line comes with what to do @@ -221,17 +263,26 @@ does too. or a sign-in that can't be read): say *"sign me in to Google again"*. The setup check has given the assistant the exact sign-in to use. A browser opens; sign in with your AAIF Google account and allow everything it asks - for. Then check your setup again. If the line says the connection file is - missing, signing in can't work yet, so do step 4 of *Set up once* instead. + for. Then check your setup again. If the line says this account can't open + the Community Intake sheet and you haven't finished step 5, do that first. If + the line says the connection file is + missing, signing in can't work yet, so do steps 3 and 4 of *Set up once* + instead. 3. **"Installed but this app cannot see it":** quit the assistant completely (⌘-Q) and open it again. 4. **The assistant seems to be guessing or doing it differently each time:** name the job, e.g. *"use the aaif-recap-post skill"*. Typing `/` in Claude Desktop lists every skill. -5. **Google says "Access blocked" when you sign in:** ask an AAIF admin to add - your address as a test user. -6. **Google asks you to sign in again about once a week:** that can be normal - for AAIF's connection. Say *"sign me in to Google again"*. +5. **Google shows an error:** + - *"Access blocked" when you sign in:* if you chose Internal, sign in with the + account that created the file. If you chose External, add yourself as a test + user (step 3, part 3). + - *`redirect_uri_mismatch` when you sign in:* your client isn't a **Desktop + app**. Create a new one and move it into place (step 3, part 4, and step 4). + - *The setup check says a Google service is turned off:* turn them on (step 3, + part 2). Signing in again won't fix this. +6. **Google asks you to sign in again about once a week:** that's normal if you + chose External in step 3. Say *"sign me in to Google again"*. 7. **Still stuck:** copy the last message the assistant showed you (it never includes your keys) and send it to an AAIF admin. diff --git a/skills/aaif-check-setup/SKILL.md b/skills/aaif-check-setup/SKILL.md index 3e2e76c..6740e45 100644 --- a/skills/aaif-check-setup/SKILL.md +++ b/skills/aaif-check-setup/SKILL.md @@ -60,9 +60,13 @@ at least one ❌ line. `USER` unset — it names its key after `$USER` and mints a second one. It opens a browser; the person signs in with their AAIF Google account and allows everything asked. - **No Google connection file** (`gws` says it has no OAuth client configured) - — signing in cannot work yet. Relay the check's next step: the person gets the - file from an AAIF admin and follows step 4 of the README's *Set up once*. Never + — signing in cannot work yet. Relay the check's next step: the person creates the + file and moves it into place, steps 3 and 4 of the README's *Set up once*. Never ask them to paste the file or its contents into the chat. +- **"This account cannot open the Community Intake sheet"** — a new person sees + this until an admin grants access, and the script still prints the sign-in + command after it. Relay the next step. Run that command only if the person + already has access and signed in with the wrong account. - **`gws` installed but not visible** — the app was opened before `gws` was installed. Quitting the app fully and reopening it is the fix; do not edit shell profiles on the person's behalf. @@ -71,7 +75,8 @@ at least one ❌ line. the keychain or click Always Allow, then re-run the check. Never relay the create-a-key steps for this case; a second item with the same name makes later lookups ambiguous. -- **A token or key is missing** — relay the script's Keychain Access steps. +- **A token or key is missing** — relay the script's whole next step: creating + the key, then the Keychain Access steps. **Never ask the person to paste a token or key into the chat**, and never put one in a command: the chat transcript and the shell history both keep it. The terminal form (`security add-generic-password ... -w`) prompts for diff --git a/skills/aaif-check-setup/scripts/check_setup.py b/skills/aaif-check-setup/scripts/check_setup.py index 724ef1d..35a0815 100755 --- a/skills/aaif-check-setup/scripts/check_setup.py +++ b/skills/aaif-check-setup/scripts/check_setup.py @@ -229,7 +229,7 @@ def stray_gws_key(): #: Not on SIGN_IN_LINES: the sign-in command cannot work until this is fixed. NO_CLIENT = "`gws` has no usable Google connection file yet, so you cannot sign in." #: Not on SIGN_IN_LINES either: signing in again cannot turn a service on. -API_OFF = "A Google service the toolkit needs is turned off for AAIF's Google connection." +API_OFF = "A Google service the toolkit needs is turned off for your Google connection." SIGN_IN_LINES = (SIGN_IN_UNREADABLE, SIGN_IN_NO_DRIVE, SIGN_IN_NONE, SIGN_IN_WRONG_ACCOUNT) @@ -282,8 +282,8 @@ def check_google(): if (is_sign_in_failure(text) and "failed to decrypt" not in text and not has_oauth_client()): return NEEDED, NO_CLIENT, ( - "Follow step 4 of the README's 'Set up once' section. If you " - "don't have the Google connection file, ask an AAIF admin for it.") + "Create your Google connection file and move it into place: " + "steps 3 and 4 of the README's 'Set up once' section.") if "failed to decrypt" in text: # Seen live 2026-10-09: gws names its keychain key after $USER, so a # run with USER unset minted a second `gws-cli` key under @@ -307,12 +307,13 @@ def check_google(): "permissions; a browser opens — use your AAIF Google account.") if "accessnotconfigured" in text or "has not been used in project" in text: return NEEDED, API_OFF, ( - "Send this line to an AAIF admin, who can turn it on (first-time " - "setup in MAINTAINING.md).") + "Turn the Google services on: step 3, part 2, of the README's " + "'Set up once' section.") if any(w in text for w in ("404", "not found", "403")): return NEEDED, SIGN_IN_WRONG_ACCOUNT, ( - "Sign in again with the Google account AAIF shared the " - "Chapters folder with, or ask an admin for access.") + "If you haven't asked AAIF for access yet, do that first (step 5 " + "of the README's 'Set up once' section). Otherwise sign in again " + "with the Google account AAIF shared the Chapters folder with.") return NEEDED, "Google check failed: %s" % why, ( "Try again; if it repeats, send this line to an AAIF admin.") try: @@ -337,7 +338,7 @@ def check_slack(): return keychain_refused("Slack token", failure) if not token: return OPTIONAL, "No Slack token — needed for \"run the sync\", the Slack audit and the community update; writing jobs don't need it.", ( - "Get the AAIF Slack token from an AAIF admin. " + "Create your Slack token: step 5 of the README's 'Set up once' section. " + keychain_steps("aaif-slack-write-token", "token")) req = urllib.request.Request("https://slack.com/api/auth.test", data=b"", headers={"Authorization": "Bearer " + token}) @@ -351,7 +352,9 @@ def check_slack(): return OK, "Slack token in %s works (workspace: %s)." % ( where, body.get("team", "?")), None return NEEDED, "Slack token in %s was refused (%s)." % (where, body.get("error")), ( - "The token has expired or been revoked; ask an AAIF admin for a new one.") + "The token has expired or been revoked. Create a new one (step 5 of the " + "README's 'Set up once' section) and replace the saved one, as it " + "explains.") def check_luma(): @@ -360,8 +363,8 @@ def check_luma(): return keychain_refused("Luma key", failure) if not key: return OPTIONAL, "No Luma key — event pages will come back as copy to paste into Luma by hand.", ( - "To let the assistant publish to Luma, get the Luma key from an " - "AAIF admin. " + "To let the assistant publish to Luma, create your key: step 5 of " + "the README's 'Set up once' section. " + keychain_steps("luma-api-key", "API key")) req = urllib.request.Request("https://public-api.luma.com/v1/calendars/get", headers={"x-luma-api-key": key, @@ -372,8 +375,8 @@ def check_luma(): except urllib.error.HTTPError as e: if e.code in (401, 403): return NEEDED, "Luma key in %s was refused (HTTP %d)." % (where, e.code), ( - "The key may have been replaced; get the current one from an " - "AAIF admin.") + "The key may have been deleted. Create a new one and replace the " + "saved one: step 5 of the README's 'Set up once' section.") # A Luma outage or rate limit is not a bad key: do not send the # operator to rotate one that works. return NEEDED, "Luma key found in %s, but Luma is not answering right now (HTTP %d)." % ( diff --git a/skills/aaif-check-setup/scripts/test_check_setup.py b/skills/aaif-check-setup/scripts/test_check_setup.py index dd073f4..a467a3a 100755 --- a/skills/aaif-check-setup/scripts/test_check_setup.py +++ b/skills/aaif-check-setup/scripts/test_check_setup.py @@ -268,7 +268,7 @@ def test_no_client_asks_for_the_file_not_a_sign_in(self): status, line, fix = self._google(client=False) self.assertEqual((status, line), (cs.NEEDED, cs.NO_CLIENT)) self.assertIn("connection file", fix) - self.assertIn("step 4", fix) + self.assertIn("steps 3 and 4", fix) self.assertNotIn("sign you in", fix) self.assertFalse(line.startswith(cs.SIGN_IN_LINES)) @@ -294,12 +294,24 @@ def test_an_unreadable_token_cache_keeps_its_own_fix(self): self.assertEqual(line, cs.SIGN_IN_UNREADABLE) def test_a_disabled_service_is_not_a_wrong_account(self): - status, line, _ = self._google( + status, line, fix = self._google( client=True, err='403 {"reason": "accessNotConfigured"}') self.assertEqual((status, line), (cs.NEEDED, cs.API_OFF)) + self.assertIn("step 3, part 2", fix) self.assertFalse(line.startswith(cs.SIGN_IN_LINES)) +class TestAccessNotGrantedYet(unittest.TestCase): + def test_no_access_points_at_the_step_that_asks_for_it(self): + with mock.patch.object(cs, "find_gws", lambda: ("/x/gws", True)), \ + mock.patch.object(cs, "has_oauth_client", lambda: True), \ + mock.patch.object(cs.subprocess, "run", lambda *a, **k: done( + 1, err="File not found: 404")): + _, line, fix = cs.check_google() + self.assertEqual(line, cs.SIGN_IN_WRONG_ACCOUNT) + self.assertIn("step 5", fix) + + class TestFindingTheClient(unittest.TestCase): CLIENT = '{"installed": {"client_id": "a"}}' @@ -350,10 +362,14 @@ def test_a_credentials_file_alone_is_not_a_client(self): class TestReadmePointer(unittest.TestCase): - def test_step_4_is_where_the_fixes_say_it_is(self): + def test_steps_3_and_4_are_where_the_fixes_say_they_are(self): with open(os.path.join(cs.ROOT, "README.md"), encoding="utf-8") as f: readme = f.read() - self.assertIn("### 4. Connect Google", readme[readme.index("## Set up once"):]) + setup = readme[readme.index("## Set up once"):] + self.assertIn("### 3. Create your Google connection file", setup) + self.assertIn("### 4. Connect Google", setup) + self.assertIn("### 5. Get your access and create your keys", setup) + self.assertIn("To replace a key later", setup) class TestKeychainSteps(unittest.TestCase):