docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// 认证回归:数据库用例需要 PLATFORM_TEST_DATABASE_URL 指向隔离且已迁移的 fixture。
|
||||
package auth
|
||||
|
||||
import (
|
||||
@@ -21,6 +22,7 @@ import (
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
)
|
||||
|
||||
// signIdentity 为 fixture kid 生成 RS256 JWT;测试公钥缓存在内存,不访问 Slack JWKS。
|
||||
func signIdentity(t *testing.T, key *rsa.PrivateKey, claims slackClaims) string {
|
||||
t.Helper()
|
||||
header := base64.RawURLEncoding.EncodeToString([]byte(`{"alg":"RS256","kid":"fixture"}`))
|
||||
@@ -36,6 +38,8 @@ func signIdentity(t *testing.T, key *rsa.PrivateKey, claims slackClaims) string
|
||||
}
|
||||
return value + "." + base64.RawURLEncoding.EncodeToString(sig)
|
||||
}
|
||||
|
||||
// TestSlackIdentityVerification 使用本地 RSA 私钥签发样本,分别破坏发行方、受众、时间、nonce、签名及算法,仅有效样本可通过。
|
||||
func TestSlackIdentityVerification(t *testing.T) {
|
||||
key, err := rsa.GenerateKey(rand.Reader, 2048)
|
||||
if err != nil {
|
||||
@@ -76,6 +80,8 @@ func TestSlackIdentityVerification(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestSlackCallbackAndExchange 使用临时 HTTP 上游和真实测试库走 Slack 起点、POST 回调、grant 兑换;拒绝回调重放并保留用户已选资料。
|
||||
func TestSlackCallbackAndExchange(t *testing.T) {
|
||||
dsn := os.Getenv("PLATFORM_TEST_DATABASE_URL")
|
||||
if dsn == "" {
|
||||
@@ -184,8 +190,10 @@ func TestSlackCallbackAndExchange(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// rewriteTransport 只把测试外部调用改写到本地上游,保留路径和请求上下文。
|
||||
type rewriteTransport struct{ destination string }
|
||||
|
||||
// RoundTrip 克隆请求后改目标,避免修改被测函数持有的原请求对象。
|
||||
func (t rewriteTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
cloned := r.Clone(r.Context())
|
||||
target, _ := url.Parse(t.destination)
|
||||
@@ -193,6 +201,7 @@ func (t rewriteTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
return http.DefaultTransport.RoundTrip(cloned)
|
||||
}
|
||||
|
||||
// TestGoogleIdentityKeepsLegacyAccount 依赖迁移 fixture 的旧 Google 身份与会话,验证新身份归一流程仍使用原账户且不删除旧会话。
|
||||
func TestGoogleIdentityKeepsLegacyAccount(t *testing.T) {
|
||||
dsn := os.Getenv("PLATFORM_TEST_DATABASE_URL")
|
||||
if dsn == "" {
|
||||
|
||||
Reference in New Issue
Block a user