Refactor all references to computer to Superbrain
release gate / check (push) Failing after 6m55s

This commit is contained in:
Andrew S Erwin
2026-10-22 00:33:44 -05:00
parent 45aa3c80aa
commit d870eece1e
84 changed files with 438 additions and 381 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ package auth
import (
"encoding/json"
"errors"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/config"
"github.com/andrew/superbrain/internal/db"
"github.com/jackc/pgx/v5/pgconn"
"log"
"net/http"
+4 -4
View File
@@ -3,15 +3,15 @@ package auth
import (
"context"
"errors"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/models"
"github.com/andrew/superbrain/internal/config"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/models"
"log"
"net/http"
"sync"
)
const ViewAsCookie = "computer_view_as"
const ViewAsCookie = "superbrain_view_as"
type SessionUser struct {
ID, Role, RealID, RealRole string
+4 -4
View File
@@ -25,7 +25,7 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/superbrain/internal/config"
"net"
"net/http"
"sort"
@@ -184,9 +184,9 @@ func clientIP(r *http.Request) string {
// SEC-2). Next only forwards an IP when TRUSTED_PROXY=1 pins the boundary
// that overwrites X-Real-IP (the shipped nginx template does).
const (
headerClientIP = "X-Computer-Client-Ip"
headerClientTs = "X-Computer-Client-Ts"
headerClientSig = "X-Computer-Client-Sig"
headerClientIP = "X-superbrain-Client-Ip"
headerClientTs = "X-superbrain-Client-Ts"
headerClientSig = "X-superbrain-Client-Sig"
// forwardSkew bounds clock skew and replay of the signed identity.
forwardSkew = 60 * time.Second
)
+4 -4
View File
@@ -7,7 +7,7 @@ import (
"strings"
"time"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/superbrain/internal/config"
"github.com/golang-jwt/jwt/v5"
)
@@ -15,7 +15,7 @@ import (
// cookie. The jwt callback stores token.id = user.id and token.provider; the
// session callback copies token.id to session.user.id (porting guide 3.1).
const (
sessionCookieName = "computer_session"
sessionCookieName = "superbrain_session"
// time.Duration is nanoseconds, so multiply by time.Second explicitly.
sessionMaxAge = 30 * 24 * 60 * 60 * time.Second // 30 days
@@ -58,7 +58,7 @@ func SignSession(u SessionUser, secret string) (string, error) {
RegisteredClaims: jwt.RegisteredClaims{
IssuedAt: jwt.NewNumericDate(now),
ExpiresAt: jwt.NewNumericDate(now.Add(sessionMaxAge)),
Issuer: "computer",
Issuer: "superbrain",
},
})
return tok.SignedString([]byte(secret))
@@ -81,7 +81,7 @@ func verifyClaims(token, secret string) (*SessionClaims, error) {
}
tok, err := jwt.ParseWithClaims(token, &SessionClaims{}, func(t *jwt.Token) (interface{}, error) {
return []byte(secret), nil
}, jwt.WithValidMethods([]string{"HS256"}), jwt.WithIssuer("computer"), jwt.WithExpirationRequired())
}, jwt.WithValidMethods([]string{"HS256"}), jwt.WithIssuer("superbrain"), jwt.WithExpirationRequired())
if err != nil {
return nil, err
}
+3 -3
View File
@@ -28,12 +28,12 @@ func TestSessionLifetimeAndVerification(t *testing.T) {
if _, e = VerifySession(token, "wrong-secret"); e == nil {
t.Fatal("accepted wrong secret")
}
expired := jwt.NewWithClaims(jwt.SigningMethodHS256, SessionClaims{UserID: "alice", RegisteredClaims: jwt.RegisteredClaims{Issuer: "computer", ExpiresAt: jwt.NewNumericDate(time.Now().Add(-time.Hour))}})
expired := jwt.NewWithClaims(jwt.SigningMethodHS256, SessionClaims{UserID: "alice", RegisteredClaims: jwt.RegisteredClaims{Issuer: "superbrain", ExpiresAt: jwt.NewNumericDate(time.Now().Add(-time.Hour))}})
v, _ := expired.SignedString([]byte("test-secret"))
if _, e = VerifySession(v, "test-secret"); e == nil {
t.Fatal("accepted expired token")
}
token256 := jwt.NewWithClaims(jwt.SigningMethodHS384, SessionClaims{UserID: "alice", RegisteredClaims: jwt.RegisteredClaims{Issuer: "computer", ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour))}})
token256 := jwt.NewWithClaims(jwt.SigningMethodHS384, SessionClaims{UserID: "alice", RegisteredClaims: jwt.RegisteredClaims{Issuer: "superbrain", ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour))}})
v, _ = token256.SignedString([]byte("test-secret"))
if _, e = VerifySession(v, "test-secret"); e == nil {
t.Fatal("accepted unexpected algorithm")
@@ -46,7 +46,7 @@ func signTestToken(t *testing.T, typ string, ttl time.Duration, ver int) string
tok := jwt.NewWithClaims(jwt.SigningMethodHS256, SessionClaims{
UserID: "alice", Type: typ, Ver: ver,
RegisteredClaims: jwt.RegisteredClaims{
Issuer: "computer",
Issuer: "superbrain",
IssuedAt: jwt.NewNumericDate(now),
ExpiresAt: jwt.NewNumericDate(now.Add(ttl)),
},
+5 -5
View File
@@ -16,12 +16,12 @@ func TestSignupValidation(t *testing.T) {
body map[string]any
}{
{"empty", map[string]any{}},
{"missing password", map[string]any{"email": "ok@computer.test"}},
{"missing password", map[string]any{"email": "ok@superbrain.test"}},
{"invalid email", map[string]any{"email": "not-an-email", "password": "long-enough-password"}},
{"email with display name", map[string]any{"email": "Name <ok@computer.test>", "password": "long-enough-password"}},
{"short password", map[string]any{"email": "ok@computer.test", "password": "short"}},
{"7 boundary password", map[string]any{"email": "ok@computer.test", "password": "1234567"}},
{"overlong password", map[string]any{"email": "ok@computer.test", "password": strings.Repeat("a", 73)}},
{"email with display name", map[string]any{"email": "Name <ok@superbrain.test>", "password": "long-enough-password"}},
{"short password", map[string]any{"email": "ok@superbrain.test", "password": "short"}},
{"7 boundary password", map[string]any{"email": "ok@superbrain.test", "password": "1234567"}},
{"overlong password", map[string]any{"email": "ok@superbrain.test", "password": strings.Repeat("a", 73)}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
+4 -4
View File
@@ -4,10 +4,10 @@ import (
"database/sql"
"encoding/json"
"errors"
"github.com/andrew/go-computer/internal/auth"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/handlers"
"github.com/andrew/superbrain/internal/auth"
"github.com/andrew/superbrain/internal/config"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/handlers"
"log"
"net/http"
"time"
+1 -1
View File
@@ -35,7 +35,7 @@ const (
tagLength = 16
versionByte = 1
legacyVersion = 0
hkdfContext = "computer/imap-password/v1"
hkdfContext = "superbrain/imap-password/v1"
)
// Key derives the 32-byte AES key from the secret using HKDF-SHA256.
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"strings"
"time"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/superbrain/internal/config"
_ "github.com/jackc/pgx/v5/stdlib"
)
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"database/sql"
"encoding/json"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/go-computer/internal/models"
"github.com/andrew/superbrain/internal/config"
"github.com/andrew/superbrain/internal/models"
)
type UserRepo struct{ db *DB }
+3 -3
View File
@@ -6,9 +6,9 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/markdown"
"github.com/andrew/go-computer/internal/preview"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/markdown"
"github.com/andrew/superbrain/internal/preview"
"net/http"
"strconv"
"strings"
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
"math"
"net/http"
"regexp"
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/andrew/go-computer/internal/auth"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/auth"
"github.com/andrew/superbrain/internal/db"
"github.com/jackc/pgx/v5/pgconn"
"io"
"log"
+3 -3
View File
@@ -4,7 +4,7 @@ import (
"net/http"
"time"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
)
// Structured export (trust phase): a single owner-scoped JSON archive that is
@@ -68,9 +68,9 @@ func HandleExport(w http.ResponseWriter, r *http.Request) {
detail["items"], detail["sharedWith"] = items, shares
exported = append(exported, detail)
}
w.Header().Set("Content-Disposition", `attachment; filename="computer-export.json"`)
w.Header().Set("Content-Disposition", `attachment; filename="superbrain-export.json"`)
respond(w, 200, object{
"format": "computer-export",
"format": "superbrain-export",
"version": 1,
"exportedAt": time.Now().UTC(),
"user": me,
+2 -2
View File
@@ -2,8 +2,8 @@ package handlers
import (
"database/sql"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/kanban"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/kanban"
"net/http"
"strings"
)
+6 -6
View File
@@ -5,12 +5,12 @@ import (
"database/sql"
"encoding/xml"
"errors"
"github.com/andrew/go-computer/internal/config"
crypt "github.com/andrew/go-computer/internal/crypto"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/netguard"
"github.com/andrew/go-computer/internal/outbound"
"github.com/andrew/go-computer/internal/signals"
"github.com/andrew/superbrain/internal/config"
crypt "github.com/andrew/superbrain/internal/crypto"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/netguard"
"github.com/andrew/superbrain/internal/outbound"
"github.com/andrew/superbrain/internal/signals"
"io"
"net"
"net/http"
+4 -4
View File
@@ -65,9 +65,9 @@ func TestParseVCardSubset(t *testing.T) {
"UID:uid-1\r\n" +
"item1.FN:Preferred Name\r\n" +
"item1.X-ABLabel:Main\r\n" +
"EMAIL;TYPE=WORK:work@computer.test\r\n" +
"EMAIL;TYPE=PREF:pref@computer.test\r\n" +
"EMAIL:plain@computer.test\r\n" +
"EMAIL;TYPE=WORK:work@superbrain.test\r\n" +
"EMAIL;TYPE=PREF:pref@superbrain.test\r\n" +
"EMAIL:plain@superbrain.test\r\n" +
"TEL;TYPE=HOME,VOICE:+1 555 0100\r\n" +
"NOTE:folded line\r\n" +
" continuation\r\n" +
@@ -87,7 +87,7 @@ func TestParseVCardSubset(t *testing.T) {
if len(v["EMAIL"]) != 3 {
t.Fatalf("repeated EMAILs not preserved: %d", len(v["EMAIL"]))
}
if got := vCardPick(v["EMAIL"]); got != "pref@computer.test" {
if got := vCardPick(v["EMAIL"]); got != "pref@superbrain.test" {
t.Fatalf("PREF selection = %q", got)
}
// vCard 4.0 numeric PREF ranks below any TYPE=PREF-free occurrence.
+8 -8
View File
@@ -7,7 +7,7 @@ import (
"regexp"
"strings"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
)
// Connected pages (Notion-like upgrades phase 3).
@@ -15,7 +15,7 @@ import (
// Page hierarchy, internal links and embedded collection views are all
// expressed in the page's Markdown, which stays the single source of truth:
//
// - [Any label](computer:page/<id>) links to another page. /pages?id=<id>
// - [Any label](superbrain:page/<id>) links to another page. /pages?id=<id>
// and page/<id> are accepted as aliases so hand-written links work too.
// - {{collection:<id>}} embeds a live collection view; an optional
// {{collection:<id>|view=<viewId>}} pins a saved view's filters/sorts.
@@ -38,10 +38,10 @@ func internalPageID(href string) (string, bool) {
href = strings.TrimSpace(strings.TrimSuffix(strings.TrimPrefix(href, "<"), ">"))
raw := ""
switch {
case strings.HasPrefix(href, "computer://page/"):
raw = strings.TrimPrefix(href, "computer://page/")
case strings.HasPrefix(href, "computer:page/"):
raw = strings.TrimPrefix(href, "computer:page/")
case strings.HasPrefix(href, "superbrain://page/"):
raw = strings.TrimPrefix(href, "superbrain://page/")
case strings.HasPrefix(href, "superbrain:page/"):
raw = strings.TrimPrefix(href, "superbrain:page/")
case strings.HasPrefix(href, "page/"):
raw = strings.TrimPrefix(href, "page/")
case strings.HasPrefix(href, "/pages/"):
@@ -50,11 +50,11 @@ func internalPageID(href string) (string, bool) {
if u, err := url.Parse(href); err == nil {
raw = u.Query().Get("id")
}
case strings.HasPrefix(href, "computer:page?id="):
case strings.HasPrefix(href, "superbrain:page?id="):
if u, err := url.Parse(href); err == nil {
raw = u.Query().Get("id")
}
case strings.HasPrefix(href, "computer://page?id="):
case strings.HasPrefix(href, "superbrain://page?id="):
if u, err := url.Parse(href); err == nil {
raw = u.Query().Get("id")
}
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"net/http"
"time"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
)
// Page revision history (trust phase). Every committed content version gets
+2 -2
View File
@@ -3,8 +3,8 @@ package handlers
import (
"context"
"database/sql"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/markdown"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/markdown"
"net/http"
"strings"
"time"
+3 -3
View File
@@ -3,9 +3,9 @@ package handlers
import (
"context"
"encoding/json"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/outbound"
"github.com/andrew/go-computer/internal/signals"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/outbound"
"github.com/andrew/superbrain/internal/signals"
"net/http"
"strings"
"time"
+1 -1
View File
@@ -2,7 +2,7 @@ package handlers
import (
"database/sql"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
"net/http"
"strings"
"time"
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
)
// Recoverable deletions (trust phase).
+1 -1
View File
@@ -1,7 +1,7 @@
package handlers
import (
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
"net/http"
)
+6 -6
View File
@@ -17,8 +17,8 @@ func collectionBookmark(t *testing.T, c apiClient, url string) string {
func TestCollectionsLifecycle(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "coll-life@computer.test")
bob := newAPIUser(t, srv, "coll-other@computer.test")
alice := newAPIUser(t, srv, "coll-life@superbrain.test")
bob := newAPIUser(t, srv, "coll-other@superbrain.test")
bm1 := collectionBookmark(t, alice, "https://127.0.0.1/one")
@@ -149,7 +149,7 @@ func TestCollectionsLifecycle(t *testing.T) {
func TestCollectionViewsFilterSortPaginate(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "coll-views@computer.test")
alice := newAPIUser(t, srv, "coll-views@superbrain.test")
col := alice.request("POST", "/api/collections", map[string]any{"name": "Pipeline"}, 201)
cid := col["id"].(string)
@@ -278,9 +278,9 @@ func TestCollectionViewsFilterSortPaginate(t *testing.T) {
func TestCollectionRevocationReachesItems(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "coll-rev@computer.test")
alice := newAPIUser(t, srv, "coll-rev@superbrain.test")
aliceID := alice.request("GET", "/api/me", nil, 200)["user"].(map[string]any)["id"].(string)
bob := newAPIUser(t, srv, "coll-rev-owner@computer.test")
bob := newAPIUser(t, srv, "coll-rev-owner@superbrain.test")
// Bob owns a bookmark and shares it with Alice; Alice puts it in HER
// collection. Revocation must make the item vanish from every surface
@@ -338,7 +338,7 @@ func TestCollectionRevocationReachesItems(t *testing.T) {
// based on the pre-reorder / pre-deletion state get 409s.
func TestCollectionIndirectMutationsAdvanceVersions(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "coll-rev@computer.test")
alice := newAPIUser(t, srv, "coll-rev@superbrain.test")
bm1 := collectionBookmark(t, alice, "https://127.0.0.1/r1")
bm2 := collectionBookmark(t, alice, "https://127.0.0.1/r2")
col := alice.request("POST", "/api/collections", map[string]any{"name": "Revisions"}, 201)
+8 -8
View File
@@ -17,8 +17,8 @@ func pageVersion(t *testing.T, c apiClient, id string) int {
func TestPageHierarchy(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "pages-tree@computer.test")
bob := newAPIUser(t, srv, "pages-tree-other@computer.test")
alice := newAPIUser(t, srv, "pages-tree@superbrain.test")
bob := newAPIUser(t, srv, "pages-tree-other@superbrain.test")
root := alice.request("POST", "/api/pages", map[string]any{"title": "Root"}, 201)["id"].(string)
child := alice.request("POST", "/api/pages", map[string]any{"title": "Child", "parentId": root}, 201)["id"].(string)
@@ -71,8 +71,8 @@ func TestPageHierarchy(t *testing.T) {
func TestPageBacklinksAndEmbeds(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "pages-graph@computer.test")
bob := newAPIUser(t, srv, "pages-graph-other@computer.test")
alice := newAPIUser(t, srv, "pages-graph@superbrain.test")
bob := newAPIUser(t, srv, "pages-graph-other@superbrain.test")
target := alice.request("POST", "/api/pages", map[string]any{"title": "Target page"}, 201)["id"].(string)
bobTarget := bob.request("POST", "/api/pages", map[string]any{"title": "Private title"}, 201)["id"].(string)
@@ -82,9 +82,9 @@ func TestPageBacklinksAndEmbeds(t *testing.T) {
foreignCollection := bob.request("POST", "/api/collections", map[string]any{"name": "Bob private"}, 201)["id"].(string)
content := "# Connected\n\n" +
"- [Target](computer:page/" + target + ")\n" +
"- [Target](superbrain:page/" + target + ")\n" +
"- [Alias](/pages?id=" + target + ")\n" +
"- [Bob's page](computer:page/" + bobTarget + ")\n\n" +
"- [Bob's page](superbrain:page/" + bobTarget + ")\n\n" +
"{{collection:" + collection + "|view=" + view + "}}\n" +
"{{collection:" + foreignCollection + "}}\n"
source := alice.request("POST", "/api/pages", map[string]any{"title": "Source page", "content": content}, 201)["id"].(string)
@@ -140,7 +140,7 @@ func TestPageBacklinksAndEmbeds(t *testing.T) {
// Re-linking re-establishes the edge; deleting the target removes it.
alice.request("PATCH", "/api/pages/"+source, map[string]any{
"content": "[Target](computer:page/" + target + ")", "version": pageVersion(t, alice, source),
"content": "[Target](superbrain:page/" + target + ")", "version": pageVersion(t, alice, source),
}, 200)
if b := alice.request("GET", "/api/pages/"+target, nil, 200)["backlinks"].([]any); len(b) != 1 {
t.Fatalf("re-link was not resolved: %v", b)
@@ -151,7 +151,7 @@ func TestPageBacklinksAndEmbeds(t *testing.T) {
}
// Self-links are ignored (a page is not its own backlink).
selfContent := "[Me](computer:page/" + source + ")"
selfContent := "[Me](superbrain:page/" + source + ")"
alice.request("PATCH", "/api/pages/"+source, map[string]any{
"content": selfContent, "version": pageVersion(t, alice, source),
}, 200)
+20 -20
View File
@@ -16,8 +16,8 @@ import (
"testing"
"time"
"github.com/andrew/go-computer/internal/auth"
"github.com/andrew/go-computer/internal/signals"
"github.com/andrew/superbrain/internal/auth"
"github.com/andrew/superbrain/internal/signals"
"github.com/emersion/go-imap/backend/memory"
imapserver "github.com/emersion/go-imap/server"
"github.com/golang-jwt/jwt/v5"
@@ -71,8 +71,8 @@ func newAPIUser(t *testing.T, srv *httptest.Server, email string) apiClient {
func TestPreviouslyUncoveredRoutes(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "coverage-alice@computer.test")
newAPIUser(t, srv, "coverage-searchable@computer.test")
alice := newAPIUser(t, srv, "coverage-alice@superbrain.test")
newAPIUser(t, srv, "coverage-searchable@superbrain.test")
// GET /api/preview — handler plumbing (auth + query + parse).
html := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -98,15 +98,15 @@ func TestPreviouslyUncoveredRoutes(t *testing.T) {
// GET /api/users/search — name substring, exact email, masked output,
// no email-substring enumeration, 2-rune guard.
users := alice.getJSON("/api/users/search?q=coverage-sea", 200)
if len(users) != 1 || users[0]["email"] != "c***@computer.test" {
if len(users) != 1 || users[0]["email"] != "c***@superbrain.test" {
t.Fatal("users/search name match:", users)
}
if users := alice.getJSON("/api/users/search?q=coverage-searchable@computer.test", 200); len(users) != 1 {
if users := alice.getJSON("/api/users/search?q=coverage-searchable@superbrain.test", 200); len(users) != 1 {
t.Fatal("users/search exact email:", users)
}
// "able@computer.test" is a substring of the target's email but not a
// "able@superbrain.test" is a substring of the target's email but not a
// full email and not part of any name: must not match.
if users := alice.getJSON("/api/users/search?q=able%40computer.test", 200); len(users) != 0 {
if users := alice.getJSON("/api/users/search?q=able%40superbrain.test", 200); len(users) != 0 {
t.Fatal("users/search must not substring-match emails:", users)
}
if users := alice.getJSON("/api/users/search?q=c", 200); len(users) != 0 {
@@ -180,9 +180,9 @@ func TestPreviouslyUncoveredRoutes(t *testing.T) {
// cookie: a token copied before signout stops working.
func TestSignoutRevokesIssuedTokens(t *testing.T) {
srv := testServer(t)
u := newAPIUser(t, srv, "revoke@computer.test")
u := newAPIUser(t, srv, "revoke@superbrain.test")
creds, _ := json.Marshal(map[string]any{"email": "revoke@computer.test", "password": "coverage-test-password"})
creds, _ := json.Marshal(map[string]any{"email": "revoke@superbrain.test", "password": "coverage-test-password"})
req, _ := http.NewRequest("POST", srv.URL+"/api/auth/login", bytes.NewReader(creds))
req.Header.Set("Content-Type", "application/json")
res, e := u.c.Do(req)
@@ -192,7 +192,7 @@ func TestSignoutRevokesIssuedTokens(t *testing.T) {
res.Body.Close()
var stale string
for _, c := range res.Cookies() {
if c.Name == "computer_session" {
if c.Name == "superbrain_session" {
stale = c.Value
}
}
@@ -205,7 +205,7 @@ func TestSignoutRevokesIssuedTokens(t *testing.T) {
// Replay the pre-signout token directly (no jar): must be rejected.
replay := func(path string) int {
rq, _ := http.NewRequest("GET", srv.URL+path, nil)
rq.AddCookie(&http.Cookie{Name: "computer_session", Value: stale})
rq.AddCookie(&http.Cookie{Name: "superbrain_session", Value: stale})
rs, e := u.c.Do(rq)
if e != nil {
t.Fatal(e)
@@ -221,7 +221,7 @@ func TestSignoutRevokesIssuedTokens(t *testing.T) {
t.Fatalf("stale cookie accepted on data route: %d", code)
}
rq, _ := http.NewRequest("GET", srv.URL+"/api/auth/session", nil)
rq.AddCookie(&http.Cookie{Name: "computer_session", Value: stale})
rq.AddCookie(&http.Cookie{Name: "superbrain_session", Value: stale})
rs, e := u.c.Do(rq)
if e != nil {
t.Fatal(e)
@@ -236,7 +236,7 @@ func TestSignoutRevokesIssuedTokens(t *testing.T) {
// One scheduler tick creates signals and marks sources checked (TEST-2).
func TestSignalSchedulerRunOnce(t *testing.T) {
srv, d := testServerDB(t)
alice := newAPIUser(t, srv, "scheduler@computer.test")
alice := newAPIUser(t, srv, "scheduler@superbrain.test")
listener, e := net.Listen("tcp", "127.0.0.1:0")
if e != nil {
@@ -282,7 +282,7 @@ func TestSignalSchedulerRunOnce(t *testing.T) {
// the per-user backoff so the next ticks are skipped.
func TestSchedulerBacksOffAfterMailboxFailure(t *testing.T) {
srv, d := testServerDB(t)
alice := newAPIUser(t, srv, "backoff@computer.test")
alice := newAPIUser(t, srv, "backoff@superbrain.test")
id := alice.request("POST", "/api/bookmarks", map[string]any{"url": "https://example.org/backoff"}, 201)["id"].(string)
alice.request("POST", "/api/bookmarks/"+id+"/signals", map[string]any{"type": "email", "config": map[string]any{"subject": "anything"}}, 201)
// Deliberately no saved IMAP configuration: every pass fails in LoadMailbox.
@@ -317,7 +317,7 @@ func TestSchedulerBacksOffAfterMailboxFailure(t *testing.T) {
// bodies (review PERF-01).
func TestPageVersionAndListProjection(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "pagever@computer.test")
alice := newAPIUser(t, srv, "pagever@superbrain.test")
created := alice.request("POST", "/api/pages", map[string]any{"title": "Doc", "content": "first"}, 201)
id := created["id"].(string)
if created["version"].(float64) != 1 {
@@ -369,7 +369,7 @@ func TestPageVersionAndListProjection(t *testing.T) {
// competing writer's committed revision.
func TestConcurrentPageSaveAckReportsOwnWrite(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "pageack@computer.test")
alice := newAPIUser(t, srv, "pageack@superbrain.test")
id := alice.request("POST", "/api/pages", map[string]any{"title": "Ack", "content": "v1"}, 201)["id"].(string)
const writers = 8
@@ -426,7 +426,7 @@ func TestConcurrentPageSaveAckReportsOwnWrite(t *testing.T) {
// the revision, and tag replacement rides the same contract.
func TestBookmarkVersionContract(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "bmver@computer.test")
alice := newAPIUser(t, srv, "bmver@superbrain.test")
created := alice.request("POST", "/api/bookmarks", map[string]any{"url": "https://example.org/ver", "title": "v0"}, 201)
id := created["id"].(string)
if created["version"].(float64) != 0 {
@@ -457,7 +457,7 @@ func TestBookmarkVersionContract(t *testing.T) {
// must revoke NextAuth-backed Bearer assertions, not just Go cookie sessions.
func TestAssertionRevocationFollowsTokenVersion(t *testing.T) {
srv, d := testServerDB(t)
u := newAPIUser(t, srv, "assert-revoke@computer.test")
u := newAPIUser(t, srv, "assert-revoke@superbrain.test")
uid := u.request("GET", "/api/me", nil, 200)["user"].(map[string]any)["id"].(string)
var ver int
if e := d.QueryRow(`SELECT "tokenVersion" FROM "User" WHERE id=$1`, uid).Scan(&ver); e != nil {
@@ -468,7 +468,7 @@ func TestAssertionRevocationFollowsTokenVersion(t *testing.T) {
tok := jwt.NewWithClaims(jwt.SigningMethodHS256, auth.SessionClaims{
UserID: uid, Type: auth.TokenTypeAssertion, Ver: v,
RegisteredClaims: jwt.RegisteredClaims{
Issuer: "computer",
Issuer: "superbrain",
IssuedAt: jwt.NewNumericDate(now),
ExpiresAt: jwt.NewNumericDate(now.Add(60 * time.Second)),
},
+9 -9
View File
@@ -3,9 +3,9 @@ package http
import (
"bytes"
"encoding/json"
"github.com/andrew/go-computer/internal/auth"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/auth"
"github.com/andrew/superbrain/internal/config"
"github.com/andrew/superbrain/internal/db"
"io"
"net/http"
"net/http/cookiejar"
@@ -128,16 +128,16 @@ func TestApplicationFlows(t *testing.T) {
post := func(email string) map[string]any {
return map[string]any{"email": email, "password": "a-long-test-password"}
}
alice.request("POST", "/api/signup", post("alice@computer.test"), 201)
bob.request("POST", "/api/signup", post("bob@computer.test"), 201)
alice.request("POST", "/api/signup", post("alice@superbrain.test"), 201)
bob.request("POST", "/api/signup", post("bob@superbrain.test"), 201)
// Review SEC-4/CR-03: a duplicate signup returns the SAME 201 {"ok":true}
// body as a fresh creation (no 409, no distinguishing field).
dup := alice.request("POST", "/api/signup", post("alice@computer.test"), 201)
dup := alice.request("POST", "/api/signup", post("alice@superbrain.test"), 201)
if len(dup) != 1 || dup["ok"] != true {
t.Fatalf("duplicate signup body differs from a fresh creation: %v", dup)
}
alice.request("POST", "/api/auth/login", post("alice@computer.test"), 200)
bob.request("POST", "/api/auth/login", post("bob@computer.test"), 200)
alice.request("POST", "/api/auth/login", post("alice@superbrain.test"), 200)
bob.request("POST", "/api/auth/login", post("bob@superbrain.test"), 200)
au := meID(alice)
bu := meID(bob)
if alice.request("GET", "/api/me", nil, 200)["isAdmin"] != true {
@@ -189,7 +189,7 @@ func TestApplicationFlows(t *testing.T) {
t.Fatal("alert dismissal")
}
putBookmark(alice, id, map[string]any{"alertAt": "2000-01-02"}, 200)
source := alice.request("POST", "/api/bookmarks/"+id+"/signals", map[string]any{"type": "email", "config": map[string]any{"from": "sender@computer.test"}}, 201)["id"].(string)
source := alice.request("POST", "/api/bookmarks/"+id+"/signals", map[string]any{"type": "email", "config": map[string]any{"from": "sender@superbrain.test"}}, 201)["id"].(string)
alice.request("POST", "/api/bookmarks/"+id+"/signals", map[string]any{"action": "check"}, 200)
alice.request("PATCH", "/api/signal-sources/"+source, map[string]any{"enabled": false}, 200)
bob.request("DELETE", "/api/signal-sources/"+source, nil, 404)
+10 -10
View File
@@ -3,8 +3,8 @@ package http
import (
"context"
"encoding/json"
crypt "github.com/andrew/go-computer/internal/crypto"
"github.com/andrew/go-computer/internal/signals"
crypt "github.com/andrew/superbrain/internal/crypto"
"github.com/andrew/superbrain/internal/signals"
"github.com/emersion/go-imap/backend/memory"
imapserver "github.com/emersion/go-imap/server"
"io"
@@ -22,7 +22,7 @@ func TestExternalIntegrations(t *testing.T) {
srv, d := testServerDB(t)
jar, _ := cookiejar.New(nil)
a := apiClient{t, &http.Client{Jar: jar}, srv.URL}
credentials := map[string]any{"email": "integrations@computer.test", "password": "test-password"}
credentials := map[string]any{"email": "integrations@superbrain.test", "password": "test-password"}
a.request("POST", "/api/signup", credentials, 201)
a.request("POST", "/api/auth/login", credentials, 200)
// CardDAV fixture (reviews CR-07/CR-08): the served multistatus is
@@ -48,14 +48,14 @@ func TestExternalIntegrations(t *testing.T) {
card1 := `<d:response><d:href>/card.vcf</d:href><d:propstat><d:prop><card:address-data>BEGIN:VCARD
UID:contact-1
FN:Contact Name
EMAIL:last@computer.test
EMAIL;TYPE=PREF:preferred@computer.test
EMAIL:last@superbrain.test
EMAIL;TYPE=PREF:preferred@superbrain.test
TEL:1234
END:VCARD</card:address-data></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response>`
card2 := `<d:response><d:href>/card2.vcf</d:href><d:propstat><d:prop><card:address-data>BEGIN:VCARD
UID:contact-2
FN:Second Contact
EMAIL:second@computer.test
EMAIL:second@superbrain.test
END:VCARD</card:address-data></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response>`
card2Withheld := `<d:response><d:href>/card2.vcf</d:href><d:propstat><d:prop/><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response>`
wrap := func(responses ...string) string {
@@ -85,7 +85,7 @@ END:VCARD</card:address-data></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:pr
t.Fatal("CardDAV import count", contacts)
}
for _, c := range contacts {
if c["uid"] == "contact-1" && c["email"] != "preferred@computer.test" {
if c["uid"] == "contact-1" && c["email"] != "preferred@superbrain.test" {
t.Fatal("repeated EMAIL did not resolve to the PREF value:", c)
}
}
@@ -173,7 +173,7 @@ END:VCARD</card:address-data></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:pr
// Nextcloud URL is rejected at the API boundary — no dial, no credentials.
func TestCardDAVRequiresTLSOutsideFixtures(t *testing.T) {
srv := testServer(t)
a := newAPIUser(t, srv, "carddav-tls@computer.test")
a := newAPIUser(t, srv, "carddav-tls@superbrain.test")
t.Setenv("INTEGRATIONS_ALLOW_PRIVATE", "")
a.request("POST", "/api/contacts/sync", map[string]any{
"nextcloudUrl": "http://nextcloud.example.test", "username": "u", "password": "p",
@@ -194,7 +194,7 @@ func TestCardDAVRequiresTLSOutsideFixtures(t *testing.T) {
// rewrites the password column at all.
func TestImapCredentialWritesNeverRestoreStalePasswords(t *testing.T) {
srv, d := testServerDB(t)
alice := newAPIUser(t, srv, "imap-stale@computer.test")
alice := newAPIUser(t, srv, "imap-stale@superbrain.test")
t.Setenv("ENCRYPTION_KEY", "dedicated-encryption-key")
uid := alice.request("GET", "/api/me", nil, 200)["user"].(map[string]any)["id"].(string)
@@ -246,6 +246,6 @@ func TestImapCredentialWritesNeverRestoreStalePasswords(t *testing.T) {
// A masked save with no stored configuration is a 400, never an empty
// or resurrected password.
bob := newAPIUser(t, srv, "imap-nocfg@computer.test")
bob := newAPIUser(t, srv, "imap-nocfg@superbrain.test")
bob.request("POST", "/api/settings/imap", map[string]any{"host": "h.example.test", "port": 993, "tls": true, "username": "user", "password": "••••••••", "folder": "INBOX"}, 400)
}
+2 -2
View File
@@ -7,7 +7,7 @@ import "testing"
// still honors the bookmark concurrency version (review CR-04).
func TestKanbanCardMovePersistsOrdering(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "kanban-order@computer.test")
alice := newAPIUser(t, srv, "kanban-order@superbrain.test")
cols := alice.getJSON("/api/kanban/columns", 200)
if len(cols) < 2 {
t.Fatalf("expected default columns, got %d", len(cols))
@@ -113,7 +113,7 @@ func TestKanbanCardMovePersistsOrdering(t *testing.T) {
}
// Foreign columns are never accepted.
bob := newAPIUser(t, srv, "kanban-other@computer.test")
bob := newAPIUser(t, srv, "kanban-other@superbrain.test")
bobCols := bob.getJSON("/api/kanban/columns", 200)
foreign := bobCols[0]["id"].(string)
firstNow := alice.request("GET", "/api/bookmarks/"+first["id"].(string), nil, 200)
+3 -3
View File
@@ -10,8 +10,8 @@ import (
// trigram indexes introduced alongside the escaping change.
func TestPageSearchEscapesWildcards(t *testing.T) {
srv, d := testServerDB(t)
alice, _ := accountClient(t, srv.URL, "pagesearch@computer.test")
other, _ := accountClient(t, srv.URL, "pagesearch-other@computer.test")
alice, _ := accountClient(t, srv.URL, "pagesearch@superbrain.test")
other, _ := accountClient(t, srv.URL, "pagesearch-other@superbrain.test")
alice.request("POST", "/api/pages", map[string]any{"title": "100% done", "content": "literal percent"}, 201)
alice.request("POST", "/api/pages", map[string]any{"title": "100x done", "content": "not a percent"}, 201)
@@ -44,7 +44,7 @@ func TestPageSearchEscapesWildcards(t *testing.T) {
// instead of persisting them (the 1 MiB body cap alone is too coarse).
func TestTextFieldSizeLimits(t *testing.T) {
srv := testServer(t)
alice, _ := accountClient(t, srv.URL, "limits@computer.test")
alice, _ := accountClient(t, srv.URL, "limits@superbrain.test")
const (
urlLimit = 2048
+1 -1
View File
@@ -12,7 +12,7 @@ import (
// every file twice in order cannot change the backfill guarantees.
func TestUpgradeBackfillsLegacyWatchesWithoutChangingExistingSources(t *testing.T) {
srv, d := testServerDB(t)
_, uid := accountClient(t, srv.URL, "watcher@computer.test")
_, uid := accountClient(t, srv.URL, "watcher@superbrain.test")
if _, err := d.Exec(`INSERT INTO "Bookmark"(id,url,"ownerId","imapWatchEnabled","imapQuery") VALUES('old','https://127.0.0.1',$1,true,'Invoices'),('paused','https://127.0.0.1',$1,true,'Receipts'),('off','https://127.0.0.1',$1,false,'Other')`, uid); err != nil {
t.Fatal(err)
}
+2 -2
View File
@@ -9,8 +9,8 @@ import (
func TestBookmarkPaginationPreservesCollectionAndOwnership(t *testing.T) {
srv, d := testServerDB(t)
owner, uid := accountClient(t, srv.URL, "owner@computer.test")
other, oid := accountClient(t, srv.URL, "other@computer.test")
owner, uid := accountClient(t, srv.URL, "owner@superbrain.test")
other, oid := accountClient(t, srv.URL, "other@superbrain.test")
for _, user := range []string{uid, oid} {
if _, err := d.Exec(`INSERT INTO "Bookmark"(id,url,title,"ownerId","updatedAt") SELECT $1||'-'||lpad(n::text,4,'0'),'https://127.0.0.1/test','Match '||n,$1,'2026-10-07T12:00:00Z' FROM generate_series(1,205) n`, user); err != nil {
t.Fatal(err)
+12 -12
View File
@@ -42,8 +42,8 @@ func rawCall(t *testing.T, c apiClient, method, path string, body []byte, header
// one of them win and the other observe the committed count.
func TestConcurrentAdminDemotionsKeepOneAdmin(t *testing.T) {
srv, d := testServerDB(t)
a, _ := accountClient(t, srv.URL, "admin-a@computer.test")
b, bID := accountClient(t, srv.URL, "admin-b@computer.test")
a, _ := accountClient(t, srv.URL, "admin-a@superbrain.test")
b, bID := accountClient(t, srv.URL, "admin-b@superbrain.test")
a.request("PATCH", "/api/admin/users", map[string]any{"userId": bID, "role": "ADMIN"}, 200)
aID := meID(a)
@@ -93,7 +93,7 @@ func TestSignupTrimsWhitespaceName(t *testing.T) {
srv, _ := testServerDB(t)
jar, _ := cookiejar.New(nil)
c := apiClient{t, &http.Client{Jar: jar}, srv.URL}
body := map[string]any{"email": "trimmed@computer.test", "password": "test-long-password", "name": " "}
body := map[string]any{"email": "trimmed@superbrain.test", "password": "test-long-password", "name": " "}
c.request("POST", "/api/signup", body, 201)
c.request("POST", "/api/auth/login", body, 200)
me := c.request("GET", "/api/me", nil, 200)
@@ -107,7 +107,7 @@ func TestSignupTrimsWhitespaceName(t *testing.T) {
// INSERT per id inside a user-locked transaction.
func TestShareRecipientListsAreCapped(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "cap-owner@computer.test")
owner, _ := accountClient(t, srv.URL, "cap-owner@superbrain.test")
id := owner.request("POST", "/api/bookmarks", map[string]any{"url": "https://example.com/cap"}, 201)["id"].(string)
tooMany := make([]string, maxTestShareRecipients+1)
@@ -132,7 +132,7 @@ const (
// Review L-8: an oversized direct API body is 413, not a misleading 400.
func TestOversizedDirectBodyReturns413(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "oversized@computer.test")
owner, _ := accountClient(t, srv.URL, "oversized@superbrain.test")
body := []byte(`{"url":"https://example.com","notes":"` + strings.Repeat("a", 1<<20) + `"}`)
status, _ := rawCall(t, owner, "POST", "/api/bookmarks", body, nil)
if status != http.StatusRequestEntityTooLarge {
@@ -144,7 +144,7 @@ func TestOversizedDirectBodyReturns413(t *testing.T) {
// endpoints, while an idempotent same-origin call still succeeds.
func TestSignoutRejectsCrossOrigin(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "signout@computer.test")
owner, _ := accountClient(t, srv.URL, "signout@superbrain.test")
body := []byte(`{}`)
status, _ := rawCall(t, owner, "POST", "/api/auth/signout", body, map[string]string{"Origin": "https://attacker.invalid"})
if status != http.StatusForbidden {
@@ -160,7 +160,7 @@ func TestSignoutRejectsCrossOrigin(t *testing.T) {
// groups instead of trusting a client to keep them apart.
func TestPageReorderKeepsPinnedGrouping(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "reorder@computer.test")
owner, _ := accountClient(t, srv.URL, "reorder@superbrain.test")
pinned := owner.request("POST", "/api/pages", map[string]any{"title": "Pinned", "pinned": true}, 201)["id"].(string)
second := owner.request("POST", "/api/pages", map[string]any{"title": "Second"}, 201)["id"].(string)
third := owner.request("POST", "/api/pages", map[string]any{"title": "Third"}, 201)["id"].(string)
@@ -193,7 +193,7 @@ func TestPageReorderKeepsPinnedGrouping(t *testing.T) {
// rejected instead of silently discarded.
func TestPropertyConfigRejectsMalformedValues(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "props@computer.test")
owner, _ := accountClient(t, srv.URL, "props@superbrain.test")
cid := owner.request("POST", "/api/collections", map[string]any{"name": "Config"}, 201)["id"].(string)
for _, cfg := range []any{"x", []any{}, 5, true} {
owner.request("POST", "/api/collections/"+cid+"/properties", map[string]any{"name": "Bad", "type": "TEXT", "config": cfg}, 400)
@@ -206,8 +206,8 @@ func TestPropertyConfigRejectsMalformedValues(t *testing.T) {
// creating duplicate calendar entries.
func TestSharedDateReshareIsIdempotent(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "dates-owner@computer.test")
_, recipientID := accountClient(t, srv.URL, "dates-recipient@computer.test")
owner, _ := accountClient(t, srv.URL, "dates-owner@superbrain.test")
_, recipientID := accountClient(t, srv.URL, "dates-recipient@superbrain.test")
post := func(note string) []map[string]any {
body, _ := json.Marshal(map[string]any{"date": "2026-11-05", "note": note, "recipientIds": []string{recipientID}})
@@ -258,7 +258,7 @@ func TestSharedDateReshareIsIdempotent(t *testing.T) {
func TestCardDAVRejectsNonStandardPort(t *testing.T) {
srv, _ := testServerDB(t)
t.Setenv("INTEGRATIONS_ALLOW_PRIVATE", "0")
owner, _ := accountClient(t, srv.URL, "carddav@computer.test")
owner, _ := accountClient(t, srv.URL, "carddav@superbrain.test")
v := owner.request("POST", "/api/contacts/sync", map[string]any{
"nextcloudUrl": "https://198.51.100.10:8443",
"username": "user",
@@ -274,7 +274,7 @@ func TestCardDAVRejectsNonStandardPort(t *testing.T) {
// renumbers positions contiguously, so reload order is deterministic.
func TestColumnDeleteNormalizesMovedCardPositions(t *testing.T) {
srv, _ := testServerDB(t)
owner, _ := accountClient(t, srv.URL, "columns@computer.test")
owner, _ := accountClient(t, srv.URL, "columns@superbrain.test")
var columns []map[string]any
res, err := owner.c.Get(srv.URL + "/api/kanban/columns")
if err != nil {
+26 -26
View File
@@ -7,7 +7,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"github.com/andrew/go-computer/internal/scripts"
"github.com/andrew/superbrain/internal/scripts"
"net/http"
"net/http/cookiejar"
"os"
@@ -18,18 +18,18 @@ import (
func TestConfiguredAdminCannotBeBypassedDuringBootstrap(t *testing.T) {
srv, d := testServerDB(t)
t.Setenv("ADMIN_EMAILS", "operator@computer.test")
visitor, _ := accountClient(t, srv.URL, "visitor@computer.test")
t.Setenv("ADMIN_EMAILS", "operator@superbrain.test")
visitor, _ := accountClient(t, srv.URL, "visitor@superbrain.test")
if visitor.request("GET", "/api/me", nil, 200)["isAdmin"] != false {
t.Fatal("public signup bypassed reserved administrator bootstrap")
}
visitor.request("GET", "/api/admin/users", nil, 403)
t.Setenv("SEED_EMAIL", "operator@computer.test")
t.Setenv("SEED_EMAIL", "operator@superbrain.test")
t.Setenv("SEED_PASSWORD", "operator-test-password")
if err := scripts.Seed(context.Background(), d); err != nil {
t.Fatal(err)
}
visitor.request("POST", "/api/auth/login", map[string]any{"email": "operator@computer.test", "password": "operator-test-password"}, 200)
visitor.request("POST", "/api/auth/login", map[string]any{"email": "operator@superbrain.test", "password": "operator-test-password"}, 200)
if visitor.request("GET", "/api/me", nil, 200)["isAdmin"] != true {
t.Fatal("operator-provisioned account is not admin")
}
@@ -37,7 +37,7 @@ func TestConfiguredAdminCannotBeBypassedDuringBootstrap(t *testing.T) {
if err := scripts.Seed(context.Background(), d); err != nil {
t.Fatal(err)
}
visitor.request("POST", "/api/auth/login", map[string]any{"email": "operator@computer.test", "password": "operator-test-password"}, 200)
visitor.request("POST", "/api/auth/login", map[string]any{"email": "operator@superbrain.test", "password": "operator-test-password"}, 200)
}
func accountClient(t *testing.T, base, email string) (apiClient, string) {
@@ -54,14 +54,14 @@ func accountClient(t *testing.T, base, email string) (apiClient, string) {
func TestAdminEnrollmentRequiresTrustedIdentity(t *testing.T) {
srv, d := testServerDB(t)
admin, _ := accountClient(t, srv.URL, "admin@computer.test")
user, uid := accountClient(t, srv.URL, "unverified@computer.test")
t.Setenv("ADMIN_EMAILS", "reserved@computer.test,unverified@computer.test")
admin, _ := accountClient(t, srv.URL, "admin@superbrain.test")
user, uid := accountClient(t, srv.URL, "unverified@superbrain.test")
t.Setenv("ADMIN_EMAILS", "reserved@superbrain.test,unverified@superbrain.test")
// Reserved addresses answer exactly like existing accounts (no 403 oracle).
// Review SEC-4/CR-03: operator-reserved addresses return the SAME uniform
// 201 {"ok":true} body as every other accepted registration — no userId
// field, no 409.
reserved := user.request("POST", "/api/signup", map[string]any{"email": "reserved@computer.test", "password": "test-password"}, 201)
reserved := user.request("POST", "/api/signup", map[string]any{"email": "reserved@superbrain.test", "password": "test-password"}, 201)
if len(reserved) != 1 || reserved["ok"] != true {
t.Fatalf("operator-reserved address body is distinguishable: %v", reserved)
}
@@ -80,9 +80,9 @@ func TestAdminEnrollmentRequiresTrustedIdentity(t *testing.T) {
func TestPublicBookmarksDoNotExposePrivateMetadata(t *testing.T) {
srv, d := testServerDB(t)
owner, uid := accountClient(t, srv.URL, "owner@computer.test")
viewer, vid := accountClient(t, srv.URL, "viewer@computer.test")
if _, err := d.Exec(`INSERT INTO "Contact"(id,uid,"displayName",email,phone,"userId") VALUES('contact','vcard','Private','private@computer.test','555-private',$1)`, uid); err != nil {
owner, uid := accountClient(t, srv.URL, "owner@superbrain.test")
viewer, vid := accountClient(t, srv.URL, "viewer@superbrain.test")
if _, err := d.Exec(`INSERT INTO "Contact"(id,uid,"displayName",email,phone,"userId") VALUES('contact','vcard','Private','private@superbrain.test','555-private',$1)`, uid); err != nil {
t.Fatal(err)
}
id := owner.request("POST", "/api/bookmarks", map[string]any{"url": "https://127.0.0.1/test", "isPublic": true, "contactId": "contact", "imapQuery": "private mailbox query", "alertAt": "2026-10-07"}, 201)["id"].(string)
@@ -112,7 +112,7 @@ func TestPublicBookmarksDoNotExposePrivateMetadata(t *testing.T) {
t.Error("shared-reader response lost tags")
}
full := owner.request("GET", "/api/bookmarks/"+id, nil, 200)
if c, _ := full["contact"].(map[string]any); c == nil || c["email"] != "private@computer.test" {
if c, _ := full["contact"].(map[string]any); c == nil || c["email"] != "private@superbrain.test" {
t.Error("owner projection lost the contact record")
}
if s, ok := full["sharedWith"].([]any); !ok || len(s) != 1 {
@@ -146,7 +146,7 @@ func TestPublicBookmarksDoNotExposePrivateMetadata(t *testing.T) {
func TestAdminBootstrapIsOneShot(t *testing.T) {
srv, d := testServerDB(t)
// Fresh installation: the first signup completes bootstrap as admin.
admin, adminID := accountClient(t, srv.URL, "first@computer.test")
admin, adminID := accountClient(t, srv.URL, "first@superbrain.test")
if admin.request("GET", "/api/me", nil, 200)["isAdmin"] != true {
t.Fatal("first signup on a fresh installation was not admin")
}
@@ -155,7 +155,7 @@ func TestAdminBootstrapIsOneShot(t *testing.T) {
if _, err := d.Exec(`UPDATE "User" SET role='USER' WHERE id=$1`, adminID); err != nil {
t.Fatal(err)
}
latecomer, _ := accountClient(t, srv.URL, "late@computer.test")
latecomer, _ := accountClient(t, srv.URL, "late@superbrain.test")
if latecomer.request("GET", "/api/me", nil, 200)["isAdmin"] != false {
t.Fatal("signup re-opened admin bootstrap after the last admin was demoted")
}
@@ -163,7 +163,7 @@ func TestAdminBootstrapIsOneShot(t *testing.T) {
if _, err := d.Exec(`DELETE FROM "User" WHERE id=$1`, adminID); err != nil {
t.Fatal(err)
}
successor, _ := accountClient(t, srv.URL, "successor@computer.test")
successor, _ := accountClient(t, srv.URL, "successor@superbrain.test")
if successor.request("GET", "/api/me", nil, 200)["isAdmin"] != false {
t.Fatal("signup re-opened admin bootstrap after the last admin was removed")
}
@@ -175,7 +175,7 @@ func TestAdminBootstrapIsOneShot(t *testing.T) {
func TestBootstrapSignupCanBeDisabled(t *testing.T) {
srv := testServer(t)
t.Setenv("ALLOW_BOOTSTRAP_SIGNUP", "0")
visitor, _ := accountClient(t, srv.URL, "unclaimed@computer.test")
visitor, _ := accountClient(t, srv.URL, "unclaimed@superbrain.test")
if visitor.request("GET", "/api/me", nil, 200)["isAdmin"] != false {
t.Fatal("first signup became admin despite ALLOW_BOOTSTRAP_SIGNUP=0")
}
@@ -191,7 +191,7 @@ func TestDirectLoginRejectsBrowserForgery(t *testing.T) {
{"text/plain", "https://attacker.invalid", 415},
{"application/json", "https://attacker.invalid", 403},
} {
req, _ := http.NewRequest("POST", srv.URL+"/api/auth/login", bytes.NewBufferString(`{"email":"attacker@computer.test","password":"password"}`))
req, _ := http.NewRequest("POST", srv.URL+"/api/auth/login", bytes.NewBufferString(`{"email":"attacker@superbrain.test","password":"password"}`))
req.Header.Set("Content-Type", tc.contentType)
req.Header.Set("Origin", tc.origin)
res, err := http.DefaultClient.Do(req)
@@ -222,9 +222,9 @@ func TestLoginLockoutHonorsSignedForwardedIdentity(t *testing.T) {
req.Header.Set("Content-Type", "application/json")
if ip != "" {
hip, hts, sig := sign(ip, ts)
req.Header.Set("X-Computer-Client-Ip", hip)
req.Header.Set("X-Computer-Client-Ts", hts)
req.Header.Set("X-Computer-Client-Sig", sig)
req.Header.Set("X-superbrain-Client-Ip", hip)
req.Header.Set("X-superbrain-Client-Ts", hts)
req.Header.Set("X-superbrain-Client-Sig", sig)
}
res, e := http.DefaultClient.Do(req)
if e != nil {
@@ -236,21 +236,21 @@ func TestLoginLockoutHonorsSignedForwardedIdentity(t *testing.T) {
now := time.Now().Unix()
// Browser A: five failures lock out its (IP, email) bucket.
for i := 0; i < 5; i++ { // failureThreshold
if code := post("victim-a@computer.test", "wrong-password", "198.51.100.1", now); code != 401 {
if code := post("victim-a@superbrain.test", "wrong-password", "198.51.100.1", now); code != 401 {
t.Fatalf("browser A attempt %d: %d", i+1, code)
}
}
if code := post("victim-a@computer.test", "wrong-password", "198.51.100.1", now); code != 429 {
if code := post("victim-a@superbrain.test", "wrong-password", "198.51.100.1", now); code != 429 {
t.Fatalf("browser A not locked out: %d", code)
}
// Browser B behind the same proxy peer keeps its own buckets.
if code := post("victim-a@computer.test", "wrong-password", "198.51.100.2", now); code != 401 {
if code := post("victim-a@superbrain.test", "wrong-password", "198.51.100.2", now); code != 401 {
t.Fatalf("browser B locked out by browser A's failures: %d", code)
}
// A stale signature (outside the ~60s window) falls back to the peer, so
// it cannot smuggle a fresh identity: these attempts count against the
// peer bucket and stay 401.
if code := post("victim-b@computer.test", "wrong-password", "198.51.100.9", now-3600); code != 401 {
if code := post("victim-b@superbrain.test", "wrong-password", "198.51.100.9", now-3600); code != 401 {
t.Fatalf("stale signature changed behavior: %d", code)
}
}
+6 -6
View File
@@ -6,12 +6,12 @@ import (
"os"
"time"
"github.com/andrew/go-computer/internal/auth"
"github.com/andrew/go-computer/internal/authguard"
"github.com/andrew/go-computer/internal/config"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/handlers"
"github.com/andrew/go-computer/internal/oidc"
"github.com/andrew/superbrain/internal/auth"
"github.com/andrew/superbrain/internal/authguard"
"github.com/andrew/superbrain/internal/config"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/handlers"
"github.com/andrew/superbrain/internal/oidc"
)
// NewServer builds the HTTP server with all routes registered.
+2 -2
View File
@@ -19,8 +19,8 @@ func TestRevocationAndForeignRelations(t *testing.T) {
// uniform signup body.
return meID(c)
}
account(a, "owner@computer.test")
bid := account(b, "recipient@computer.test")
account(a, "owner@superbrain.test")
bid := account(b, "recipient@superbrain.test")
tag := a.request("POST", "/api/tags", map[string]any{"name": "Shared"}, 201)["id"].(string)
id := a.request("POST", "/api/bookmarks", map[string]any{"url": "https://127.0.0.1/test", "tagIds": []string{tag}, "dueDate": "2026-10-07"}, 201)["id"].(string)
a.request("POST", "/api/bookmarks/"+id+"/share", map[string]any{"userIds": []string{bid}}, 200)
+9 -9
View File
@@ -9,8 +9,8 @@ import (
func TestPageRevisionHistory(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "trust-history@computer.test")
bob := newAPIUser(t, srv, "trust-history-other@computer.test")
alice := newAPIUser(t, srv, "trust-history@superbrain.test")
bob := newAPIUser(t, srv, "trust-history-other@superbrain.test")
page := alice.request("POST", "/api/pages", map[string]any{"title": "History", "content": "version one"}, 201)["id"].(string)
revisions := alice.getJSON("/api/pages/"+page+"/revisions", 200)
@@ -52,8 +52,8 @@ func TestPageRevisionHistory(t *testing.T) {
func TestTrashRestoreNeverResurrectsGrants(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "trust-trash@computer.test")
bob := newAPIUser(t, srv, "trust-trash-other@computer.test")
alice := newAPIUser(t, srv, "trust-trash@superbrain.test")
bob := newAPIUser(t, srv, "trust-trash-other@superbrain.test")
bobID := meID(bob)
tag := alice.request("POST", "/api/tags", map[string]any{"name": "Restored tag"}, 201)["id"].(string)
@@ -162,9 +162,9 @@ func TestTrashRestoreNeverResurrectsGrants(t *testing.T) {
func TestCollectionSharingPermissionBoundary(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "trust-coll-share@computer.test")
bob := newAPIUser(t, srv, "trust-coll-recipient@computer.test")
carol := newAPIUser(t, srv, "trust-coll-third@computer.test")
alice := newAPIUser(t, srv, "trust-coll-share@superbrain.test")
bob := newAPIUser(t, srv, "trust-coll-recipient@superbrain.test")
carol := newAPIUser(t, srv, "trust-coll-third@superbrain.test")
bobID, carolID := meID(bob), meID(carol)
bm := alice.request("POST", "/api/bookmarks", map[string]any{"url": "https://127.0.0.1/collection-share", "title": "Shared via project", "notes": "secret owner notes", "isPublic": true}, 201)
@@ -249,7 +249,7 @@ func TestCollectionSharingPermissionBoundary(t *testing.T) {
func TestStructuredExport(t *testing.T) {
srv := testServer(t)
alice := newAPIUser(t, srv, "trust-export@computer.test")
alice := newAPIUser(t, srv, "trust-export@superbrain.test")
tag := alice.request("POST", "/api/tags", map[string]any{"name": "Export tag"}, 201)["id"].(string)
bm := alice.request("POST", "/api/bookmarks", map[string]any{"url": "https://127.0.0.1/export", "title": "Exported bookmark", "tagIds": []string{tag}}, 201)["id"].(string)
@@ -258,7 +258,7 @@ func TestStructuredExport(t *testing.T) {
alice.request("POST", "/api/collections/"+col+"/items", map[string]any{"bookmarkId": bm}, 201)
v := alice.request("GET", "/api/export", nil, 200)
if v["format"] != "computer-export" || v["version"].(float64) != 1 {
if v["format"] != "superbrain-export" || v["version"].(float64) != 1 {
t.Fatalf("export envelope: %v", v)
}
if len(v["bookmarks"].([]any)) != 1 || len(v["pages"].([]any)) != 1 || len(v["tags"].([]any)) != 1 || len(v["collections"].([]any)) != 1 {
+1 -1
View File
@@ -3,7 +3,7 @@ package kanban
import (
"context"
"database/sql"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
)
var DefaultColumns = []struct{ Label, Color, Key string }{{"Inbox", "#64748b", "INBOX"}, {"To Do", "#3b82f6", "TODO"}, {"In Progress", "#f59e0b", "IN_PROGRESS"}, {"Done", "#22c55e", "DONE"}}
+2 -2
View File
@@ -2,7 +2,7 @@ package markdown
import (
"fmt"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
"net/http"
"regexp"
"strings"
@@ -82,7 +82,7 @@ func PageDocument(p db.Object) string {
out += "\n"
}
}
return out + "\n<!-- exported from computer " + text(p, "updatedAt") + " -->\n"
return out + "\n<!-- exported from superbrain " + text(p, "updatedAt") + " -->\n"
}
func Send(w http.ResponseWriter, body, name string) {
w.Header().Set("Content-Type", "text/markdown; charset=utf-8")
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"strings"
"testing"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
)
// Review L-11: link destinations are wrapped and escaped so parentheses or
+3 -3
View File
@@ -3,8 +3,8 @@ package preview
import (
"context"
"fmt"
"github.com/andrew/go-computer/internal/netguard"
"github.com/andrew/go-computer/internal/outbound"
"github.com/andrew/superbrain/internal/netguard"
"github.com/andrew/superbrain/internal/outbound"
"golang.org/x/net/html"
"io"
"net"
@@ -109,7 +109,7 @@ func FetchPreview(ctx context.Context, key, raw string) Preview {
if e != nil {
return Preview{}
}
req.Header.Set("User-Agent", "Mozilla/5.0 (compatible; computer/1.0)")
req.Header.Set("User-Agent", "Mozilla/5.0 (compatible; superbrain/1.0)")
resp, e := previewClient.Do(req)
if e != nil {
return Preview{}
+1 -1
View File
@@ -3,7 +3,7 @@ package scripts
import (
"context"
"fmt"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
"golang.org/x/crypto/bcrypt"
"os"
"strings"
+2 -2
View File
@@ -122,9 +122,9 @@ func newTestMailboxValidity(t *testing.T, n int, validity uint32) (Mailbox, *val
memMbox := mbox.(*memory.Mailbox)
memMbox.Messages = memMbox.Messages[:0]
for i := 0; i < n; i++ {
body := "From: sender@computer.test\r\n" +
body := "From: sender@superbrain.test\r\n" +
"Subject: subject " + fmt.Sprint(i) + "\r\n" +
"Message-Id: <msg-" + fmt.Sprint(i) + "@computer.test>\r\n" +
"Message-Id: <msg-" + fmt.Sprint(i) + "@superbrain.test>\r\n" +
"\r\n" + "body"
memMbox.Messages = append(memMbox.Messages, &memory.Message{
Uid: uint32(i + 1),
+1 -1
View File
@@ -2,7 +2,7 @@ package signals
import (
"context"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/superbrain/internal/db"
"log"
"sync"
"time"
+4 -4
View File
@@ -6,10 +6,10 @@ import (
"database/sql"
"errors"
"fmt"
"github.com/andrew/go-computer/internal/config"
crypt "github.com/andrew/go-computer/internal/crypto"
"github.com/andrew/go-computer/internal/db"
"github.com/andrew/go-computer/internal/netguard"
"github.com/andrew/superbrain/internal/config"
crypt "github.com/andrew/superbrain/internal/crypto"
"github.com/andrew/superbrain/internal/db"
"github.com/andrew/superbrain/internal/netguard"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/client"
"log"