A lexicon-driven AppView for ATProto. happyview.dev
backfill firehose jetstream atproto appview oauth lexicon
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: fix auth tests

Trezy 2d9cc017 62b5c3a6

+33 -21
+1 -1
migrations/postgres/20260320000000_create_instance_settings.sql
··· 1 1 CREATE TABLE instance_settings ( 2 2 key TEXT PRIMARY KEY, 3 3 value TEXT NOT NULL, 4 - updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() 4 + updated_at TEXT NOT NULL DEFAULT (NOW()::text) 5 5 );
+8 -4
src/xrpc/query.rs
··· 34 34 35 35 let limit: i64 = params 36 36 .get("limit") 37 - .and_then(|v| v.as_str()) 38 - .and_then(|l| l.parse().ok()) 37 + .and_then(|v| { 38 + v.as_i64() 39 + .or_else(|| v.as_str().and_then(|s| s.parse().ok())) 40 + }) 39 41 .unwrap_or(20) 40 42 .min(100); 41 43 42 44 let offset: i64 = params 43 45 .get("cursor") 44 - .and_then(|v| v.as_str()) 45 - .and_then(|c| c.parse().ok()) 46 + .and_then(|v| { 47 + v.as_i64() 48 + .or_else(|| v.as_str().and_then(|s| s.parse().ok())) 49 + }) 46 50 .unwrap_or(0); 47 51 48 52 let did = params.get("did").and_then(|v| v.as_str());
+14 -5
tests/common/auth.rs
··· 1 1 use axum::http::{HeaderName, HeaderValue}; 2 + use axum::response::IntoResponse; 2 3 use axum_extra::extract::cookie::{Cookie, Key, SignedCookieJar}; 3 4 4 5 /// Build a Cookie header containing a signed session cookie for the given DID. ··· 9 10 cookie.set_path("/"); 10 11 let jar = jar.add(cookie); 11 12 12 - // Extract the Set-Cookie value and convert to a Cookie request header 13 - let cookie_header = jar 13 + // Build a response to extract the Set-Cookie header with the signed value, 14 + // then convert it to a Cookie request header. 15 + let response = jar.into_response(); 16 + let set_cookie_values: Vec<String> = response 17 + .headers() 18 + .get_all("set-cookie") 14 19 .iter() 15 - .map(|c| format!("{}={}", c.name(), c.value())) 16 - .collect::<Vec<_>>() 17 - .join("; "); 20 + .filter_map(|v| { 21 + let s = v.to_str().ok()?; 22 + // Extract just "name=value" from "name=value; Path=/; ..." 23 + Some(s.split(';').next()?.to_string()) 24 + }) 25 + .collect(); 26 + let cookie_header = set_cookie_values.join("; "); 18 27 19 28 ( 20 29 HeaderName::from_static("cookie"),
+10 -11
tests/e2e_xrpc.rs
··· 36 36 .unwrap() 37 37 } 38 38 39 - fn authed_get(uri: &str, token: &str) -> Request<Body> { 40 - Request::builder() 41 - .uri(uri) 42 - .header("authorization", format!("Bearer {token}")) 43 - .body(Body::empty()) 44 - .unwrap() 45 - } 46 - 47 39 async fn seed_lexicons(app: &TestApp) { 48 40 // Record lexicon 49 41 app.router ··· 141 133 #[ignore] 142 134 async fn profile_with_mocked_services_returns_200() { 143 135 let app = TestApp::new().await; 144 - let did = "did:plc:testuser"; 136 + let did = &app.admin_did; 145 137 146 138 // Mock PLC directory 147 139 Mock::given(method("GET")) ··· 160 152 .mount(&app.mock_server) 161 153 .await; 162 154 155 + let cookie = app.admin_cookie(); 163 156 let resp = app 164 157 .router 165 158 .clone() 166 - .oneshot(authed_get("/xrpc/app.bsky.actor.getProfile", "valid-token")) 159 + .oneshot( 160 + Request::builder() 161 + .uri("/xrpc/app.bsky.actor.getProfile") 162 + .header(cookie.0, cookie.1) 163 + .body(Body::empty()) 164 + .unwrap(), 165 + ) 167 166 .await 168 167 .unwrap(); 169 168 170 169 assert_eq!(resp.status(), StatusCode::OK); 171 170 let json = json_body(resp).await; 172 - assert_eq!(json["did"], did); 171 + assert_eq!(json["did"], did.as_str()); 173 172 assert_eq!(json["displayName"], "Test User"); 174 173 } 175 174