feat: 统一 Commilitia Drop 全客户端命名与分发

This commit is contained in:
2026-07-31 22:56:10 +08:00
parent f7b0f04c9c
commit c480f0d1c2
77 changed files with 861 additions and 263 deletions
+6 -6
View File
@@ -55,7 +55,7 @@ func TestLogin_Success(t *testing.T) {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(map[string]any{
"id": "sid-1",
"app": "cdrop",
"app": "commilitia-drop",
"access": "at-123",
"refresh": "rtk-456",
"access_expires": time.Now().Add(15 * time.Minute).Unix(),
@@ -63,7 +63,7 @@ func TestLogin_Success(t *testing.T) {
}))
defer brokerSrv.Close()
cfg := OAuthConfig{BrokerURL: brokerSrv.URL, App: "cdrop"}
cfg := OAuthConfig{BrokerURL: brokerSrv.URL, App: "commilitia-drop"}
// Fake browser: parse the /device/authorize URL, assert it carries app + PKCE,
// then GET the loopback redirect with a code + the same state (approved).
@@ -80,7 +80,7 @@ func TestLogin_Success(t *testing.T) {
if q.Get("code_challenge") == "" || q.Get("code_challenge_method") != "S256" {
t.Errorf("authorize request missing PKCE challenge: %v", q)
}
if q.Get("app") != "cdrop" {
if q.Get("app") != "commilitia-drop" {
t.Errorf("authorize app = %q", q.Get("app"))
}
cb := q.Get("redirect_uri") + "?code=auth-code-xyz&state=" + url.QueryEscape(q.Get("state"))
@@ -119,7 +119,7 @@ func TestLogin_Success(t *testing.T) {
}
func TestLogin_StateMismatch(t *testing.T) {
cfg := OAuthConfig{BrokerURL: "https://sso.example.net", App: "cdrop"}
cfg := OAuthConfig{BrokerURL: "https://sso.example.net", App: "commilitia-drop"}
openURL := func(authURL string) {
u, _ := url.Parse(authURL)
redirect := u.Query().Get("redirect_uri")
@@ -157,7 +157,7 @@ func TestRefresh_Success(t *testing.T) {
}))
defer brokerSrv.Close()
cfg := OAuthConfig{BrokerURL: brokerSrv.URL, App: "cdrop"}
cfg := OAuthConfig{BrokerURL: brokerSrv.URL, App: "commilitia-drop"}
tok, err := NewFlow(cfg, func(string) {}).Refresh(context.Background(), "old-rtk")
if err != nil {
t.Fatalf("Refresh: %v", err)
@@ -174,7 +174,7 @@ func TestRefresh_Success(t *testing.T) {
}
func TestRefresh_EmptyToken(t *testing.T) {
cfg := OAuthConfig{BrokerURL: "https://sso.example.net", App: "cdrop"}
cfg := OAuthConfig{BrokerURL: "https://sso.example.net", App: "commilitia-drop"}
if _, err := NewFlow(cfg, func(string) {}).Refresh(context.Background(), ""); err == nil {
t.Fatal("want error for empty refresh token")
}