feat: 统一 Commilitia Drop 全客户端命名与分发
This commit is contained in:
+11
-11
@@ -83,7 +83,7 @@ func newMockBroker(t *testing.T) (*brokerclient.Client, *mockBrokerState) {
|
||||
}
|
||||
st.sessions[sid] = &mockSession{sid: sid, userID: userID, app: app, meta: meta, sub: str(body, "sub"), label: label, scope: scope, createdAt: created, lastUsedAt: now}
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{
|
||||
"id": sid, "app": "cdrop",
|
||||
"id": sid, "app": "commilitia-drop",
|
||||
"access": "acc-" + sid, "refresh": "rtk-" + sid,
|
||||
"access_expires": time.Now().Add(15 * time.Minute).Unix(),
|
||||
"refresh_expires": time.Now().Add(24 * time.Hour).Unix(),
|
||||
@@ -128,7 +128,7 @@ func newMockBroker(t *testing.T) (*brokerclient.Client, *mockBrokerState) {
|
||||
}
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
return brokerclient.New(srv.URL, "test-key", "cdrop"), st
|
||||
return brokerclient.New(srv.URL, "test-key", "commilitia-drop"), st
|
||||
}
|
||||
|
||||
// newQRTestServer builds a Server with only the fields the scan-login + device
|
||||
@@ -332,10 +332,10 @@ func TestRequireFullSession_GuestBlockedFullPasses(t *testing.T) {
|
||||
handler.ServeHTTP(w, r)
|
||||
return w.Code
|
||||
}
|
||||
if c := check("app:cdrop:guest"); c != http.StatusForbidden {
|
||||
if c := check("app:commilitia-drop:guest"); c != http.StatusForbidden {
|
||||
t.Errorf("guest on full-only route: got %d, want 403", c)
|
||||
}
|
||||
if c := check("app:cdrop:full"); c != http.StatusOK {
|
||||
if c := check("app:commilitia-drop:full"); c != http.StatusOK {
|
||||
t.Errorf("full on full-only route: got %d, want 200", c)
|
||||
}
|
||||
}
|
||||
@@ -365,8 +365,8 @@ func TestDeleteDevice_RevokesBrokerSession(t *testing.T) {
|
||||
if !st.revoked["sid-1"] {
|
||||
t.Error("broker session sid-1 was not revoked")
|
||||
}
|
||||
if st.lastRevokeApp != "cdrop" {
|
||||
t.Errorf("revoke X-Broker-App: got %q, want cdrop", st.lastRevokeApp)
|
||||
if st.lastRevokeApp != "commilitia-drop" {
|
||||
t.Errorf("revoke X-Broker-App: got %q, want commilitia-drop", st.lastRevokeApp)
|
||||
}
|
||||
if _, err := s.queries.GetDevice(context.Background(), got.DeviceID); err == nil {
|
||||
t.Error("device row should be gone after delete")
|
||||
@@ -381,7 +381,7 @@ func TestSessionsList_ShowsDevices(t *testing.T) {
|
||||
got := decodeStatus(t, qrStatus(s, start.RequestID, start.PollSecret))
|
||||
|
||||
r := httptest.NewRequest(http.MethodGet, "/api/auth/sessions", nil)
|
||||
r = r.WithContext(jwtauth.ContextWithClaims(r.Context(), &jwtauth.Claims{UserID: "owner", Scope: "app:cdrop:guest", DeviceID: got.DeviceID}))
|
||||
r = r.WithContext(jwtauth.ContextWithClaims(r.Context(), &jwtauth.Claims{UserID: "owner", Scope: "app:commilitia-drop:guest", DeviceID: got.DeviceID}))
|
||||
w := httptest.NewRecorder()
|
||||
s.handleSessionsList(w, r)
|
||||
if w.Code != http.StatusOK {
|
||||
@@ -462,7 +462,7 @@ func TestDeviceSession_MintsManagedDevice(t *testing.T) {
|
||||
if st.lastMint["tier"] != "full" || st.lastMint["meta"] != "dev_browser01" || st.lastMint["label"] != "Laptop" {
|
||||
t.Errorf("mint params: %+v", st.lastMint)
|
||||
}
|
||||
list := listSessions(t, s, "owner", "app:cdrop:full", "dev_browser01")
|
||||
list := listSessions(t, s, "owner", "app:commilitia-drop:full", "dev_browser01")
|
||||
if len(list) != 1 || list[0].DeviceID != "dev_browser01" || list[0].Kind != "browser" || !list[0].Current {
|
||||
t.Errorf("unified list wrong: %+v", list)
|
||||
}
|
||||
@@ -474,7 +474,7 @@ func TestDeviceSession_Idempotent(t *testing.T) {
|
||||
s, _ := newQRTestServer(t)
|
||||
_ = deviceSession(t, s, "owner", "full", "dev_same01", "Laptop", "browser", "")
|
||||
_ = deviceSession(t, s, "owner", "full", "dev_same01", "Laptop Renamed", "browser", "")
|
||||
list := listSessions(t, s, "owner", "app:cdrop:full", "dev_same01")
|
||||
list := listSessions(t, s, "owner", "app:commilitia-drop:full", "dev_same01")
|
||||
if len(list) != 1 {
|
||||
t.Fatalf("idempotent re-mint: got %d sessions, want 1", len(list))
|
||||
}
|
||||
@@ -493,7 +493,7 @@ func TestSessionsList_FiltersMetalessBootstrap(t *testing.T) {
|
||||
t.Fatalf("bootstrap mint: %v", err)
|
||||
}
|
||||
_ = deviceSession(t, s, "owner", "full", "dev_real01", "Laptop", "browser", "")
|
||||
list := listSessions(t, s, "owner", "app:cdrop:full", "dev_real01")
|
||||
list := listSessions(t, s, "owner", "app:commilitia-drop:full", "dev_real01")
|
||||
if len(list) != 1 || list[0].DeviceID != "dev_real01" {
|
||||
t.Fatalf("metaless bootstrap not filtered: %+v", list)
|
||||
}
|
||||
@@ -517,7 +517,7 @@ func TestDeviceSession_RejectsCrossOrigin(t *testing.T) {
|
||||
// A restricted guest minting its device session stays guest — no escalation to full.
|
||||
func TestDeviceSession_GuestTierNotEscalated(t *testing.T) {
|
||||
s, st := newQRTestServer(t)
|
||||
_ = deviceSession(t, s, "owner", "app:cdrop:guest", "dev_guest01", "Borrowed", "browser", "")
|
||||
_ = deviceSession(t, s, "owner", "app:commilitia-drop:guest", "dev_guest01", "Borrowed", "browser", "")
|
||||
if st.lastMint["tier"] != "guest" {
|
||||
t.Errorf("guest caller minted tier %v, want guest", st.lastMint["tier"])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user