chadtmiller.com/group-host
atmosphere group host
0
0
The console shows who is signed in, approves apps, and is tested end to end
.knotless/workflows/e2e.ymlnew+78−0
| @@ -0,0 +1,78 @@ | ||
# The console used as people use it, as `just e2e` runs it: in Chromium, | ||
# signed in to through the reference PDS's own approval page, an app | ||
# signed in as a group through it and writing as the group, an app | ||
# declined, and signing out (harness/e2e/flows.spec.mjs), over a world | ||
# seeded for the run (harness/e2e/setup.mjs). The tests show the host's | ||
# methods do what they say; this, that the console and the host and a PDS | ||
# do it together. Each flow that fails leaves the page as it was then | ||
# among the check's outputs, as a picture. As knotless's e2e.yml. | ||
# | ||
# Node, the packages, Chromium, the libraries it needs and the build are | ||
# kept between runs, as main's runs leave them: nothing is fetched again | ||
# until what it is made from changes. | ||
image: rust:1.98 | ||
# Every push to main, and pulls into it or a feature/ branch that change | ||
# the console, the host it asks, the lexicons, the harness it runs over, or | ||
# this file. A pull changing none passes at once, noted as skipped. | ||
on: | ||
push: {refs: [refs/heads/main]} | ||
pull: | ||
base: [refs/heads/main, refs/heads/feature/*] | ||
paths: [web/**, lexicons/**, crates/**, Cargo.toml, Cargo.lock, harness/e2e/**, harness/pds.mjs, harness/tls-proxy.mjs, harness/package.json, harness/package-lock.json, .knotless/workflows/e2e.yml, .knotless/uses.lock] | ||
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, /opt/browsers, /opt/chromium-debs, web/node_modules, harness/node_modules] | ||
env: | ||
PLAYWRIGHT_BROWSERS_PATH: /opt/browsers | ||
steps: | ||
- uses: chadtmiller.com/steps/node@1 | ||
with: {version: 24.22.1} | ||
- uses: chadtmiller.com/steps/npm-ci@1 | ||
name: web | ||
with: {dir: web} | ||
- uses: chadtmiller.com/steps/npm-ci@1 | ||
name: harness | ||
with: {dir: harness} | ||
- name: chromium | ||
run: | | ||
export PATH=/opt/node/bin:$PATH | ||
cd harness | ||
# The browser, into /opt/browsers once for each Playwright version. | ||
npx playwright install chromium | ||
# The libraries it needs, which `install-deps` would fetch with apt on | ||
# every run: their .debs are kept, fetched again only when this | ||
# Playwright or this Debian asks for others, and installed offline. | ||
pkgs=$(npx playwright install-deps --dry-run chromium | sed -n "s/.*--no-install-recommends \([^\"']*\).*/\1/p") | ||
[ -n "$pkgs" ] || { echo "no packages in: $(npx playwright install-deps --dry-run chromium)"; exit 1; } | ||
debs=/opt/chromium-debs | ||
want="$(. /etc/os-release && echo "$VERSION_ID") $pkgs" | ||
if [ "$(cat $debs/.want 2>/dev/null)" != "$want" ]; then | ||
rm -rf "${debs:?}"/* && mkdir -p $debs/partial | ||
apt-get update -qq | ||
apt-get install -y -qq --no-install-recommends --download-only -o Dir::Cache::archives=$debs $pkgs | ||
echo "$want" > $debs/.want | ||
fi | ||
dpkg -i $debs/*.deb > /dev/null | ||
- name: sqlite | ||
run: | | ||
# The stock PDS's SQLite module, which the install above skips building. | ||
export PATH=/opt/node/bin:$PATH | ||
dir="$(dirname "$(node -p "require.resolve('better-sqlite3/package.json', { paths: ['harness'] })")")" | ||
[ -f "$dir/build/Release/better_sqlite3.node" ] || (cd "$dir" && npm run install) | ||
- name: build | ||
run: | | ||
export PATH=/opt/node/bin:$PATH | ||
# The host and the console side by side, as neither needs the other. | ||
cargo build -p group-host & cargo=$! | ||
(cd web && npm run build) || { kill $cargo; exit 1; } | ||
wait $cargo | ||
- name: flows | ||
run: | | ||
export PATH=/opt/node/bin:$PATH | ||
status=0 | ||
(cd harness && npx playwright test -c e2e/playwright.config.mjs) || status=$? | ||
# The page each failed flow ended on, named for the flow. | ||
if [ -n "${KNOTLESS_RUN_OUTPUTS:-}" ] && [ -d target/e2e ]; then | ||
for shot in target/e2e/*/*/test-failed-*.png; do | ||
[ -f "$shot" ] && cp "$shot" "$KNOTLESS_RUN_OUTPUTS/$(basename "$(dirname "$shot")").png" | ||
done | ||
fi | ||
exit $status | ||
crates/group-host/src/actors.rsnew+104−0
| @@ -0,0 +1,104 @@ | ||
//! People, as the console shows them: who is asking (`getViewer`, as | ||
//! knotless's), and the groups someone is in (`getActorGroups`). | ||
//! | ||
//! As the prototype's `methods/groups.ts`'s `getActorGroups`. | ||
| ||
use crate::Host; | ||
use crate::api::{Params, page, param}; | ||
use crate::group::{members_space, meta_space}; | ||
use crate::group_api::{caller, group_of, signed_in}; | ||
use crate::rbac::{Access, NS}; | ||
use crate::xrpc::XrpcError; | ||
use atproto::did; | ||
use axum::Json; | ||
use axum::extract::{Query, State}; | ||
use axum::http::{HeaderMap, StatusCode}; | ||
use serde_json::{Value, json}; | ||
use std::sync::Arc; | ||
| ||
type Answer = Result<Json<Value>, XrpcError>; | ||
| ||
/// Who is asking, by the console's cookie or service auth: nothing, for | ||
/// no one. | ||
pub async fn get_viewer(State(host): State<Arc<Host>>, headers: HeaderMap) -> Answer { | ||
let Some(me) = caller(&host, &headers, &format!("{NS}.getViewer")).await? else { | ||
return Ok(Json(json!({}))); | ||
}; | ||
let mut actor = json!({"did": me, "canCreateGroup": host.may_found(&me)}); | ||
let doc = host.identity.document(&me).await.ok(); | ||
if let Some(handle) = doc.as_ref().and_then(did::handle) { | ||
actor["handle"] = json!(handle); | ||
} | ||
Ok(Json(json!({ "actor": actor }))) | ||
} | ||
| ||
impl Host { | ||
/// A group as a list of someone's shows it, to `viewer`, a member: its | ||
/// name and picture as they may read them, and how many are in it. | ||
fn group_view_basic(&self, group: &str, viewer: &str) -> Answer { | ||
let handle = group_of(self, group)?; | ||
let mut view = json!({"did": group, "handle": handle}); | ||
if let Some(address) = self.store.address(group).map_err(XrpcError::internal)? { | ||
view["address"] = json!(address); | ||
} | ||
let roles = self.roles(group, viewer).map_err(XrpcError::internal)?; | ||
let meta = meta_space(group); | ||
let access = self.group_record(group, &meta, &format!("{NS}.access"), "self"); | ||
let access = access.map_err(XrpcError::internal)?.unwrap_or_default(); | ||
if Access::of(&access).can_read(&roles, viewer) { | ||
let profile = self.group_record(group, &meta, &format!("{NS}.profile"), "self"); | ||
let profile = profile.map_err(XrpcError::internal)?.unwrap_or_default(); | ||
if let Some(name) = profile.get("displayName") { | ||
view["displayName"] = name.clone(); | ||
} | ||
if let Some(cid) = profile["avatar"]["ref"]["$link"].as_str() { | ||
view["avatar"] = json!(cid); | ||
} | ||
} | ||
let members = self.group_records(group, &members_space(group), &format!("{NS}.membership")); | ||
view["memberCount"] = json!(members.map_err(XrpcError::internal)?.len()); | ||
Ok(Json(view)) | ||
} | ||
} | ||
| ||
/// The groups here someone is in: every one of the caller's own, and of | ||
/// anyone else's only those the caller is in too, a group's members being | ||
/// its members' alone to know. By DID, a page at a time. | ||
pub async fn get_actor_groups( | ||
State(host): State<Arc<Host>>, | ||
Query(p): Query<Params>, | ||
headers: HeaderMap, | ||
) -> Answer { | ||
let me = signed_in(&host, &headers, &format!("{NS}.getActorGroups")).await?; | ||
let asked = param(&p, "actor")?.trim_start_matches('@').to_lowercase(); | ||
let actor = match asked.starts_with("did:") { | ||
true => Some(asked.clone()), | ||
false => { | ||
host.identity | ||
.resolve_handle(&asked, &host.config.handle_resolvers) | ||
.await | ||
} | ||
}; | ||
let not_found = || XrpcError::new(StatusCode::BAD_REQUEST, "ActorNotFound", "no such actor"); | ||
let actor = actor.ok_or_else(not_found)?; | ||
let limit = page(&p, 50, 100)? as usize; | ||
let after = p.get("cursor").map(String::as_str).unwrap_or_default(); | ||
let mine = host.groups_of(&me)?; | ||
let mut theirs: Vec<String> = host | ||
.groups_of(&actor)? | ||
.into_iter() | ||
.filter(|g| mine.contains(g) && g.as_str() > after) | ||
.collect(); | ||
theirs.sort(); | ||
let more = theirs.len() > limit; | ||
theirs.truncate(limit); | ||
let mut groups = Vec::new(); | ||
for group in &theirs { | ||
groups.push(host.group_view_basic(group, &me)?.0); | ||
} | ||
let mut out = json!({ "groups": groups }); | ||
if more { | ||
out["cursor"] = json!(theirs.last()); | ||
} | ||
Ok(Json(out)) | ||
} | ||
crates/group-host/src/authorization.rs+1−1
| @@ -66,7 +66,7 @@ impl Host { | ||
} | ||
| ||
/// The groups here, switched on, where `member` holds a role. | ||
fn groups_of(&self, member: &str) -> Result<Vec<String>, XrpcError> { | ||
pub(crate) fn groups_of(&self, member: &str) -> Result<Vec<String>, XrpcError> { | ||
let accounts = self.store.accounts(None, u32::MAX); | ||
let mut groups = Vec::new(); | ||
for (did, _) in accounts.map_err(XrpcError::internal)? { | ||
crates/group-host/src/lib.rs+6−0
| @@ -3,6 +3,7 @@ | ||
//! `fyi.opensocial.*` methods that run a group. `docs/design/README.md` | ||
//! says how it is built and what is still to come. | ||
| ||
pub mod actors; | ||
pub mod api; | ||
pub mod app_passwords; | ||
pub mod authority; | ||
| @@ -350,6 +351,11 @@ pub fn router(host: Arc<Host>) -> Router { | ||
"/xrpc/fyi.opensocial.revokeGroupToken", | ||
post(group_tokens::revoke_group_token), | ||
) | ||
.route("/xrpc/fyi.opensocial.getViewer", get(actors::get_viewer)) | ||
.route( | ||
"/xrpc/fyi.opensocial.getActorGroups", | ||
get(actors::get_actor_groups), | ||
) | ||
.route("/oauth/authorize", get(oauth::authorize)) | ||
.route( | ||
"/console/client-metadata.json", | ||
crates/group-host/tests/actors.rsnew+173−0
| @@ -0,0 +1,173 @@ | ||
//! Who is asking, and the groups someone is in. | ||
| ||
mod common; | ||
| ||
use common::groups::*; | ||
use common::spaces::*; | ||
use common::{Running, start}; | ||
use group_host::group::members_space; | ||
use group_host::repo::Write; | ||
use serde_json::{Value as Json, json}; | ||
| ||
async fn join(h: &Running, did: &str, who: &str) { | ||
let value = json!({"$type": format!("{NS}.membership"), "member": who, "roles": [{"role": "member"}], "createdAt": "2026-11-03T00:00:00Z"}); | ||
let write = Write::Create { | ||
collection: format!("{NS}.membership"), | ||
rkey: who.into(), | ||
value, | ||
}; | ||
h.host | ||
.space_write(did, &members_space(did), &[write]) | ||
.await | ||
.unwrap(); | ||
} | ||
| ||
async fn viewer(h: &Running, who: Option<&Authority>) -> Json { | ||
let lxm = format!("{NS}.getViewer"); | ||
let headers: Vec<(&str, String)> = who.map(|w| auth(h, w, &lxm)).into_iter().collect(); | ||
let (status, said) = get(h, &lxm, "", &headers).await; | ||
assert_eq!(status, 200, "{said}"); | ||
said | ||
} | ||
| ||
async fn groups_of(h: &Running, who: &Authority, query: &str) -> (u16, Json) { | ||
let lxm = format!("{NS}.getActorGroups"); | ||
get(h, &lxm, query, &[auth(h, who, &lxm)]).await | ||
} | ||
| ||
fn dids(said: &Json) -> Vec<&str> { | ||
said["groups"] | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.map(|g| g["did"].as_str().unwrap()) | ||
.collect() | ||
} | ||
| ||
#[tokio::test] | ||
async fn says_who_is_asking() { | ||
let h = start(&[], false).await; | ||
let [alice, ..] = people(&h).await; | ||
assert_eq!(viewer(&h, None).await, json!({})); | ||
let said = viewer(&h, Some(&alice)).await; | ||
assert_eq!(said["actor"]["did"], alice.did.as_str()); | ||
assert_eq!(said["actor"]["handle"], "authority.test"); | ||
assert_eq!(said["actor"]["canCreateGroup"], true); | ||
let h = start(&[("GROUP_FOUNDERS", "did:plc:someone")], false).await; | ||
let [alice, ..] = people(&h).await; | ||
assert_eq!( | ||
viewer(&h, Some(&alice)).await["actor"]["canCreateGroup"], | ||
false | ||
); | ||
} | ||
| ||
#[tokio::test] | ||
async fn lists_the_groups_someone_is_in_that_the_caller_is_in_too() { | ||
let h = start(&[], false).await; | ||
let [alice, bob, carol] = people(&h).await; | ||
let riders = start_group( | ||
&h, | ||
&alice, | ||
json!({"handle": RIDERS, "displayName": "Riders"}), | ||
) | ||
.await; | ||
let hikers = start_group( | ||
&h, | ||
&alice, | ||
json!({"handle": "hikers.groups.test", "displayName": "Hikers"}), | ||
) | ||
.await; | ||
let quiet = start_group(&h, &alice, json!({"handle": "quiet.groups.test", "displayName": "Quiet", "metaReadableBy": [{"role": "admin"}]})).await; | ||
join(&h, &riders, &bob.did).await; | ||
join(&h, &quiet, &bob.did).await; | ||
| ||
let (status, mine) = groups_of(&h, &alice, &format!("actor={}", alice.did)).await; | ||
assert_eq!(status, 200, "{mine}"); | ||
let mut all = vec![riders.as_str(), hikers.as_str(), quiet.as_str()]; | ||
all.sort(); | ||
assert_eq!(dids(&mine), all); | ||
let at_riders = mine["groups"] | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.find(|g| g["did"] == riders.as_str()) | ||
.unwrap(); | ||
assert_eq!(at_riders["handle"], RIDERS); | ||
assert_eq!(at_riders["displayName"], "Riders"); | ||
assert_eq!(at_riders["memberCount"], 2); | ||
assert!(at_riders["address"].is_string()); | ||
| ||
// Of Bob's, only those Alice is in too; of Alice's, only those Bob is. | ||
let (_, bobs) = groups_of(&h, &alice, &format!("actor=@{}", bob.did)).await; | ||
let mut both = vec![riders.as_str(), quiet.as_str()]; | ||
both.sort(); | ||
assert_eq!(dids(&bobs), both); | ||
let (_, seen) = groups_of(&h, &bob, &format!("actor={}", alice.did)).await; | ||
assert_eq!(dids(&seen), both); | ||
// Whose profile Bob may not read shows him no name. | ||
let at_quiet = seen["groups"] | ||
.as_array() | ||
.unwrap() | ||
.iter() | ||
.find(|g| g["did"] == quiet.as_str()) | ||
.unwrap(); | ||
assert_eq!(at_quiet.get("displayName"), None); | ||
let (_, none) = groups_of(&h, &carol, &format!("actor={}", alice.did)).await; | ||
assert_eq!(none["groups"], json!([])); | ||
| ||
// A page at a time. | ||
let (_, first) = groups_of(&h, &alice, &format!("actor={}&limit=2", alice.did)).await; | ||
assert_eq!(dids(&first), all[..2]); | ||
let cursor = first["cursor"].as_str().unwrap(); | ||
let (_, rest) = groups_of( | ||
&h, | ||
&alice, | ||
&format!("actor={}&limit=2&cursor={cursor}", alice.did), | ||
) | ||
.await; | ||
assert_eq!(dids(&rest), all[2..]); | ||
assert_eq!(rest.get("cursor"), None); | ||
| ||
assert_eq!( | ||
groups_of(&h, &alice, "actor=nobody.invalid").await.1["error"], | ||
"ActorNotFound" | ||
); | ||
assert_eq!(groups_of(&h, &alice, "").await.0, 400); | ||
let lxm = format!("{NS}.getActorGroups"); | ||
assert_eq!( | ||
get(&h, &lxm, &format!("actor={}", alice.did), &[]).await.0, | ||
401 | ||
); | ||
} | ||
| ||
#[tokio::test] | ||
async fn shows_a_groups_picture() { | ||
let h = start(&[], false).await; | ||
let [alice, ..] = people(&h).await; | ||
let riders = start_group( | ||
&h, | ||
&alice, | ||
json!({"handle": RIDERS, "displayName": "Riders"}), | ||
) | ||
.await; | ||
let lxm = format!("{NS}.uploadImage"); | ||
let (k, v) = auth(&h, &alice, &lxm); | ||
let res = h | ||
.http | ||
.post(format!("{}/xrpc/{lxm}?group={riders}", h.url)) | ||
.header(k, v) | ||
.header("content-type", "image/png") | ||
.body(b"face".to_vec()) | ||
.send() | ||
.await | ||
.unwrap(); | ||
let image: Json = res.json().await.unwrap(); | ||
let lxm = format!("{NS}.updateProfile"); | ||
let body = json!({"group": riders, "displayName": "Riders", "avatar": image["blob"]}); | ||
assert_eq!( | ||
post(&h, &lxm, &body, &[auth(&h, &alice, &lxm)]).await.0, | ||
200 | ||
); | ||
let (_, mine) = groups_of(&h, &alice, &format!("actor={}", alice.did)).await; | ||
assert_eq!(mine["groups"][0]["avatar"], image["blob"]["ref"]["$link"]); | ||
} | ||
docs/design/README.md+6−3
| @@ -107,9 +107,12 @@ says otherwise. | ||
The console signs its people in at their own PDS here, as a | ||
confidential client, as knotless does, keeping only a signed cookie | ||
(`console_login.rs`; done). | ||
7. **The console.** Home, starting a group, a group's page (members, | ||
roles, invites, requests, apps), approving an app, a person's | ||
sessions and app passwords: the console's pages in `apps/web/src/pages`. | ||
7. **The console.** Signing in as oneself (step 6); who is looking | ||
(`getViewer`, as knotless's) and their groups (`getActorGroups`), on | ||
home, and approving an app (`/authorize`; `actors.rs`; done); then | ||
starting a group, a group's page (members, roles, invites, requests, | ||
apps), a person's sessions and app passwords: the console's pages in | ||
`apps/web/src/pages`. | ||
8. **Moderation, recovery and moving.** Reports, labels, subjects and | ||
history; recovery keys; importing an account; migrating a group to | ||
another host and moving the host itself: | ||
docs/design/signing-in.md+1−3
| @@ -207,9 +207,7 @@ at the token endpoint, its client id (and its assertion, if confidential) | ||
in the body and a DPoP proof in the header. It must be one the host makes | ||
groups for (`PROVISIONING_CLIENTS`), and its scope must hold `atproto` | ||
and nothing its metadata does not declare. All of that is checked before | ||
the group is made. What follows it (narrowing the scope, issuing the | ||
grant) fails only on an internal error, which leaves the group made, and | ||
its founder's to run, with no session for the app: it asks again. The session is issued as a code exchange issues one, | ||
the group is made. The session is issued as a code exchange issues one, | ||
narrowed to the founder's roles as an approval is, and recorded as the | ||
founder's: from then on an ordinary grant, refreshed at `/oauth/token`, | ||
listed among the group's, revoked there. | ||
docs/reference/cli.md+1−0
| @@ -20,4 +20,5 @@ arrive with the methods they call (see [the order](../design/README.md#the-order | ||
| `lex` | the lexicons' checks | | ||
| `serve` | the host | | ||
| `web`, `web-dev` | the console built, or served as its source changes | | ||
| `e2e <args>` | the console's flows in Chromium over the reference PDS, as the `e2e` check runs them | | ||
| `opensocial <args>` | the command | | ||
docs/development.md+14−0
| @@ -26,6 +26,20 @@ lines and functions, tests and the harness left out. A test that starts | ||
the host or the command as a binary stops it with SIGTERM, so it exits as | ||
it should and writes the coverage it counted. | ||
| ||
## The console, end to end | ||
| ||
`just e2e` uses the console as people use it, in Chromium, with Playwright | ||
(`harness/e2e/flows.spec.mjs`), as knotless's harness does its pages: it | ||
signs in through the reference PDS's own approval page, signs an app in as | ||
a group and has it write as the group, declines one, and signs out. Its | ||
setup (`harness/e2e/setup.mjs`) runs the reference PDS, the host over it, | ||
and the built console behind an https front at `console.group-host.internal` | ||
(`harness/tls-proxy.mjs`), as the PDS reaches an OAuth client only over | ||
https at a hostname; `harness/pds.mjs` makes that name's certificate and | ||
resolves it. Chromium comes with `cd harness && npx playwright install | ||
chromium`. A failed flow leaves its trace and a picture under | ||
`target/e2e/results`. | ||
| ||
## The checks | ||
| ||
`just lint` is what `check` and `web` run: `cargo fmt --check`, clippy | ||
harness/e2e/flows.spec.mjsnew+77−0
| @@ -0,0 +1,77 @@ | ||
// What people do on the console, in order, as alice: sign in at her own | ||
// PDS, see her groups, sign an app in as one of them, and decline one; | ||
// and what the app then does as the group, read back from the host. | ||
| ||
import { expect, test } from '@playwright/test' | ||
import { App, signIn, signedInAs, url, world } from './pages.mjs' | ||
| ||
test.describe.configure({ mode: 'serial' }) | ||
| ||
let page | ||
| ||
test.beforeAll(async ({ browser }) => { | ||
page = await browser.newPage() | ||
}) | ||
| ||
test.afterAll(async () => { | ||
await page.close() | ||
}) | ||
| ||
test('signing in at her own PDS', async () => { | ||
await page.goto(url('/')) | ||
await expect(page.getByRole('heading', { name: 'Groups on this host' })).toBeVisible() | ||
await signIn(page, 'alice') | ||
await expect.poll(() => signedInAs(page)).toBe('@alice.test') | ||
}) | ||
| ||
test('seeing her groups', async () => { | ||
await expect(page.getByRole('heading', { name: 'Your groups' })).toBeVisible() | ||
await expect(page.locator('.group-row', { hasText: 'Riders' }).first()).toBeVisible() | ||
}) | ||
| ||
test('signing an app in as her group', async () => { | ||
const app = await new App('atproto repo:app.bsky.feed.post').listen() | ||
await page.goto(await app.push()) | ||
await expect(page.getByRole('heading', { name: 'Sign in an app' })).toBeVisible() | ||
await expect(page.getByText('repo:app.bsky.feed.post')).toBeVisible() | ||
await page.getByRole('button', { name: 'Sign it in as Riders' }).click() | ||
const back = await app.back | ||
app.close() | ||
expect(new URL(back).searchParams.get('state')).toBe('st4te') | ||
const tokens = await app.exchange(back) | ||
expect(tokens.sub).toBe(world.riders) | ||
expect(tokens.scope).toBe('atproto repo:app.bsky.feed.post') | ||
| ||
// The app writes as the group, and it is there. | ||
const record = { $type: 'app.bsky.feed.post', text: 'Ride on Saturday', createdAt: new Date().toISOString() } | ||
const made = await app.call('com.atproto.repo.createRecord', tokens.access_token, { | ||
repo: world.riders, | ||
collection: 'app.bsky.feed.post', | ||
record, | ||
}) | ||
expect(made.status, JSON.stringify(made.body)).toBe(200) | ||
const rkey = made.body.uri.split('/').pop() | ||
const read = await fetch(`${world.host}/xrpc/com.atproto.repo.getRecord?repo=${world.riders}&collection=app.bsky.feed.post&rkey=${rkey}`) | ||
expect((await read.json()).value.text).toBe('Ride on Saturday') | ||
}) | ||
| ||
test('declining an app', async () => { | ||
const app = await new App('atproto').listen() | ||
await page.goto(await app.push()) | ||
await page.getByRole('button', { name: 'Decline' }).click() | ||
const back = await app.back | ||
app.close() | ||
expect(new URL(back).searchParams.get('error')).toBe('access_denied') | ||
}) | ||
| ||
test('coming to a request that has lapsed', async () => { | ||
await page.goto(url('/authorize?request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3Areq-gone')) | ||
await expect(page.getByText('This sign-in request has expired')).toBeVisible() | ||
}) | ||
| ||
test('signing out', async () => { | ||
await page.goto(url('/')) | ||
await page.getByRole('button', { name: 'Sign out' }).click() | ||
await expect(page.getByRole('button', { name: 'Sign in' })).toBeVisible() | ||
await expect.poll(() => signedInAs(page)).toBe('') | ||
}) | ||