login_e2e_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. // 登录端到端测试(T4-6 验收):真 DB + 真仓储 + 真 Issuer + miniredis,走 HTTP 全链路。
  2. //
  3. // 与仓储/服务单测的差异:这里用**真实 GORM 仓储**(非 mock),覆盖"装配正确性 + 端到端"——
  4. // ① POST /auth/login(真查 t_identity/t_user,验 argon2 密码)→ code 200 + loginTicket
  5. // ② POST /auth/issue(真查 t_membership,签 token)→ code 200 + accessToken(可被本公钥验签)
  6. // ③ GET /auth/me(经 NewAuth 中间件验签 + scope 注入)→ code 200 + 正确用户
  7. // ④ 重放/越权 → code 1001/1003
  8. //
  9. // 运行前提(同仓储测试纪律:DSN 走环境变量,不入库):
  10. //
  11. // set UNIFIED_TEST_DSN=dev:xxxx@tcp(127.0.0.1:3306)/e2e_test?charset=utf8mb4&parseTime=True&loc=Local
  12. // go test ./internal/identity/handler/ -run TestLoginE2E -v
  13. //
  14. // 未设置 UNIFIED_TEST_DSN 时自动跳过(CI / 无库环境 go test ./... 不受影响)。
  15. package handler
  16. import (
  17. "context"
  18. "encoding/json"
  19. "net/http"
  20. "net/http/httptest"
  21. "os"
  22. "strings"
  23. "testing"
  24. "time"
  25. "github.com/gofiber/fiber/v2"
  26. miniredis "github.com/alicebob/miniredis/v2"
  27. "gorm.io/gorm"
  28. "yuansiwei/unified-backend/internal/identity/credential"
  29. idpkg "yuansiwei/unified-backend/internal/identity/id"
  30. "yuansiwei/unified-backend/internal/identity/model"
  31. "yuansiwei/unified-backend/internal/identity/repository"
  32. "yuansiwei/unified-backend/internal/identity/service"
  33. "yuansiwei/unified-backend/internal/identity/token"
  34. "yuansiwei/unified-backend/internal/infra/config"
  35. infra "yuansiwei/unified-backend/internal/infra/db"
  36. appredis "yuansiwei/unified-backend/internal/infra/redis"
  37. orgmodel "yuansiwei/unified-backend/internal/org/model"
  38. )
  39. // e2eDSNOrSkip 读 UNIFIED_TEST_DSN,未设置时跳过(同仓储集成测试纪律)。
  40. func e2eDSNOrSkip(t *testing.T) string {
  41. t.Helper()
  42. dsn := os.Getenv("UNIFIED_TEST_DSN")
  43. if dsn == "" {
  44. t.Skip("未设置 UNIFIED_TEST_DSN,跳过登录端到端测试")
  45. }
  46. return dsn
  47. }
  48. // e2eApp 端到端测试句柄(真库 + 真仓储 + miniredis + 真 Issuer + 路由应用)。
  49. type e2eApp struct {
  50. t *testing.T
  51. app *fiber.App
  52. pubKeys []string
  53. revocation *appredis.RevocationStore
  54. gdb *gorm.DB
  55. wechat *fakeWechat // 微信扫码打桩(code→openid 映射;供 TestWechatE2E 配置)
  56. }
  57. // e2eSetup 建真库 + AutoMigrate 4 表 + 真仓储 + miniredis + 真 Issuer + AuthService + Handler + 路由应用。
  58. func e2eSetup(t *testing.T) *e2eApp {
  59. t.Helper()
  60. dsn := e2eDSNOrSkip(t)
  61. gdb, err := infra.NewDB(config.DBCfg{DSN: dsn, MaxOpenConns: 5, MaxIdleConns: 2, ConnMaxLifetimeSec: 60})
  62. if err != nil {
  63. t.Fatalf("NewDB: %v", err)
  64. }
  65. t.Cleanup(func() { _ = infra.Close(gdb) })
  66. if err := infra.Migrate(gdb, &model.User{}, &model.Identity{}, &orgmodel.Membership{}, &orgmodel.Institution{}); err != nil {
  67. t.Fatalf("Migrate: %v", err)
  68. }
  69. t.Cleanup(func() {
  70. _ = gdb.Migrator().DropTable("t_user", "t_identity", "t_membership", "t_institution")
  71. })
  72. users := repository.NewUserRepo(gdb)
  73. identities := repository.NewIdentityRepo(gdb)
  74. memberships := repository.NewMembershipRepo(gdb)
  75. mr, err := miniredis.Run()
  76. if err != nil {
  77. t.Fatalf("miniredis.Run: %v", err)
  78. }
  79. t.Cleanup(mr.Close)
  80. rc, err := appredis.NewClient(config.RedisCfg{Addr: mr.Addr()})
  81. if err != nil {
  82. t.Fatalf("NewClient: %v", err)
  83. }
  84. t.Cleanup(func() { _ = rc.Close() })
  85. refreshStore := appredis.NewRefreshStore(rc)
  86. revocation := appredis.NewRevocationStore(rc, "revoked")
  87. tickets := appredis.NewLoginTicketStore(rc)
  88. wxStates := appredis.NewWechatQrcodeStore(rc)
  89. privPEM, pubKeys := genRSAKey(t)
  90. issuer, err := token.NewIssuer(privPEM, "https://unified.test", 30*time.Minute, 30*24*time.Hour, refreshStore, revocation)
  91. if err != nil {
  92. t.Fatalf("NewIssuer: %v", err)
  93. }
  94. svc, err := service.NewAuthService(service.Config{
  95. Users: users, Identities: identities, Memberships: memberships,
  96. Issuer: issuer, Tickets: tickets,
  97. AccessTTL: 30 * time.Minute, PublicKeys: pubKeys, IssuerStr: "https://unified.test",
  98. Revocation: revocation,
  99. })
  100. if err != nil {
  101. t.Fatalf("NewAuthService: %v", err)
  102. }
  103. // 微信扫码登录服务(真库 identities 仓储 + miniredis 双 store + 打桩 wechat.Client)
  104. fw := &fakeWechat{byCode: map[string]string{}}
  105. ws, err := service.NewWechatService(service.WechatConfig{
  106. Client: fw, States: wxStates, Tickets: tickets, Identities: identities,
  107. Campuses: []service.WechatCampus{{CampusID: 3, AppID: "appid-e2e", Secret: "secret-e2e"}},
  108. CallbackURL: "https://unified.test/auth/wechat/callback",
  109. })
  110. if err != nil {
  111. t.Fatalf("NewWechatService: %v", err)
  112. }
  113. h, err := New(Config{Svc: svc, Wechat: ws})
  114. if err != nil {
  115. t.Fatalf("New Handler: %v", err)
  116. }
  117. mw, err := NewAuth(AuthConfig{PublicKeys: pubKeys, Revocation: revocation, Issuer: "https://unified.test"})
  118. if err != nil {
  119. t.Fatalf("NewAuth: %v", err)
  120. }
  121. app := fiber.New(fiber.Config{DisableStartupMessage: true})
  122. app.Post("/auth/login", h.Login)
  123. app.Post("/auth/issue", h.Issue)
  124. app.Post("/auth/refresh", h.Refresh)
  125. app.Get("/auth/wechat/qrcode", h.WechatQrcode)
  126. app.Get("/auth/wechat/status", h.WechatStatus)
  127. app.Get("/auth/wechat/callback", h.WechatCallback)
  128. auth := app.Group("/auth")
  129. auth.Use(mw)
  130. auth.Get("/me", h.Me)
  131. auth.Post("/logout", h.Logout)
  132. return &e2eApp{t: t, app: app, pubKeys: pubKeys, revocation: revocation, gdb: gdb, wechat: fw}
  133. }
  134. // seedUser 落一个 argon2 用户 + username 身份 + 一条 membership(raw SQL 保证 created_at 确定)。
  135. func (a *e2eApp) seedUser(username, password string, inst, campus int64, role string) string {
  136. a.t.Helper()
  137. uid, err := idpkg.NewCanonicalUserID()
  138. if err != nil {
  139. a.t.Fatalf("生成 canonical user id: %v", err)
  140. }
  141. hash, err := credential.HashArgon2(password)
  142. if err != nil {
  143. a.t.Fatalf("HashArgon2: %v", err)
  144. }
  145. ctx := context.Background()
  146. now := time.Now()
  147. if err := a.gdb.WithContext(ctx).Create(&model.User{
  148. CanonicalUserID: uid, Username: ptr(username), PersonType: model.PersonTypeStaff,
  149. PasswordHash: &hash, HashVersion: ptr(model.HashVersionArgon2),
  150. Status: model.UserStatusActive, CreatedAt: now, UpdatedAt: now,
  151. }).Error; err != nil {
  152. a.t.Fatalf("插入 t_user: %v", err)
  153. }
  154. if err := a.gdb.WithContext(ctx).Create(&model.Identity{
  155. CanonicalUserID: uid, Type: model.IdentityTypeUsername, Identifier: username,
  156. Verified: true, CreatedAt: now,
  157. }).Error; err != nil {
  158. a.t.Fatalf("插入 t_identity: %v", err)
  159. }
  160. if err := a.gdb.WithContext(ctx).Exec(
  161. `INSERT INTO t_membership (canonical_user_id, institution_id, campus_id, role, status, joined_at, created_at)
  162. VALUES (?, ?, ?, ?, 'active', ?, ?)`,
  163. uid, inst, campus, role, now, now,
  164. ).Error; err != nil {
  165. a.t.Fatalf("插入 t_membership: %v", err)
  166. }
  167. return uid
  168. }
  169. // post 发 POST 请求并解出统一信封。
  170. func (a *e2eApp) post(path, body string) *envelope {
  171. a.t.Helper()
  172. req := httptest.NewRequest(http.MethodPost, path, strings.NewReader(body))
  173. resp, err := a.app.Test(req, -1)
  174. if err != nil {
  175. a.t.Fatalf("POST %s 请求失败: %v", path, err)
  176. }
  177. var env envelope
  178. if err := json.NewDecoder(resp.Body).Decode(&env); err != nil {
  179. a.t.Fatalf("POST %s 解析响应: %v", path, err)
  180. }
  181. return &env
  182. }
  183. // get 发 GET 请求(无 body、无鉴权头;微信扫码公开端点用)并解出统一信封。
  184. func (a *e2eApp) get(path string) *envelope {
  185. a.t.Helper()
  186. req := httptest.NewRequest(http.MethodGet, path, nil)
  187. resp, err := a.app.Test(req, -1)
  188. if err != nil {
  189. a.t.Fatalf("GET %s 请求失败: %v", path, err)
  190. }
  191. var env envelope
  192. if err := json.NewDecoder(resp.Body).Decode(&env); err != nil {
  193. a.t.Fatalf("GET %s 解析响应: %v", path, err)
  194. }
  195. return &env
  196. }
  197. // getBearer 带 Bearer 头请求并解出统一信封。
  198. func (a *e2eApp) getBearer(path, bearer string) *envelope {
  199. a.t.Helper()
  200. req := httptest.NewRequest(http.MethodGet, path, nil)
  201. req.Header.Set("Authorization", "Bearer "+bearer)
  202. resp, err := a.app.Test(req, -1)
  203. if err != nil {
  204. a.t.Fatalf("GET %s 请求失败: %v", path, err)
  205. }
  206. var env envelope
  207. if err := json.NewDecoder(resp.Body).Decode(&env); err != nil {
  208. a.t.Fatalf("GET %s 解析响应: %v", path, err)
  209. }
  210. return &env
  211. }
  212. // TestLoginE2E 登录全链路:login① → issue② → me(验签 + scope 注入)→ 重放/越权拒绝。
  213. func TestLoginE2E(t *testing.T) {
  214. a := e2eSetup(t)
  215. uid := a.seedUser("e2euser", "e2e-pass-123", 11, 3, "teacher")
  216. // ① login:真查 t_identity/t_user + argon2 验密 → 200 + loginTicket
  217. step1 := a.post(`/auth/login`, `{"username":"e2euser","password":"e2e-pass-123"}`)
  218. if step1.Code != 200 {
  219. t.Fatalf("login code=%d msg=%s(期望 200)", step1.Code, step1.Message)
  220. }
  221. var l1 struct {
  222. LoginTicket string `json:"loginTicket"`
  223. User struct {
  224. ID string `json:"id"`
  225. } `json:"user"`
  226. Memberships []struct {
  227. InstitutionID int64 `json:"institutionId"`
  228. CampusID int64 `json:"campusId"`
  229. Role string `json:"role"`
  230. } `json:"memberships"`
  231. }
  232. if err := json.Unmarshal(step1.Data, &l1); err != nil {
  233. t.Fatalf("解析 login data: %v", err)
  234. }
  235. if l1.User.ID != uid {
  236. t.Fatalf("login user.id=%q(期望 %q)", l1.User.ID, uid)
  237. }
  238. if len(l1.Memberships) != 1 || l1.Memberships[0].Role != "teacher" {
  239. t.Fatalf("login memberships=%+v(期望 1 条 teacher)", l1.Memberships)
  240. }
  241. // ② issue:真查 t_membership + 签 token → 200 + accessToken
  242. issueBody := `{"loginTicket":"` + l1.LoginTicket + `","institutionId":11,"campusId":3}`
  243. issueRes := a.post(`/auth/issue`, issueBody)
  244. if issueRes.Code != 200 {
  245. t.Fatalf("issue code=%d msg=%s(期望 200)", issueRes.Code, issueRes.Message)
  246. }
  247. var pair struct {
  248. AccessToken string `json:"accessToken"`
  249. RefreshToken string `json:"refreshToken"`
  250. InstitutionID int64 `json:"institutionId"`
  251. Roles []string `json:"roles"`
  252. }
  253. if err := json.Unmarshal(issueRes.Data, &pair); err != nil {
  254. t.Fatalf("解析 issue data: %v", err)
  255. }
  256. if pair.AccessToken == "" || pair.RefreshToken == "" {
  257. t.Fatal("accessToken/refreshToken 缺失")
  258. }
  259. if pair.InstitutionID != 11 || len(pair.Roles) != 1 || pair.Roles[0] != "teacher" {
  260. t.Fatalf("issue pair=%+v(期望 inst=11 roles=[teacher])", pair)
  261. }
  262. // access 可被本公钥验签 + claims 正确
  263. claims, err := token.Verify(context.Background(), a.pubKeys, a.revocation, "https://unified.test", pair.AccessToken)
  264. if err != nil {
  265. t.Fatalf("验签 access 失败: %v", err)
  266. }
  267. if claims.Sub != uid || claims.InstitutionID != 11 || claims.CampusID != 3 {
  268. t.Fatalf("claims=%+v(期望 %q/11/3)", claims, uid)
  269. }
  270. // ③ me:经 NewAuth 中间件验签 + scope 注入 → 200 + 正确用户
  271. meRes := a.getBearer(`/auth/me`, pair.AccessToken)
  272. if meRes.Code != 200 {
  273. t.Fatalf("me code=%d msg=%s(期望 200)", meRes.Code, meRes.Message)
  274. }
  275. var me struct {
  276. ID string `json:"id"`
  277. InstitutionID int64 `json:"institutionId"`
  278. CampusID int64 `json:"campusId"`
  279. }
  280. if err := json.Unmarshal(meRes.Data, &me); err != nil {
  281. t.Fatalf("解析 me data: %v", err)
  282. }
  283. if me.ID != uid || me.InstitutionID != 11 || me.CampusID != 3 {
  284. t.Fatalf("me=%+v(期望 %q/11/3)", me, uid)
  285. }
  286. // ④ 重放票据:② 已消费(GETDEL),再用同一 issueBody → 1001
  287. if replay := a.post(`/auth/issue`, issueBody); replay.Code != 1001 {
  288. t.Fatalf("重放 issue code=%d(期望 1001 票据已消费)", replay.Code)
  289. }
  290. // ⑤ 越权作用域:新票据挑不属于自己的 (inst,campus) → 1003
  291. step1b := a.post(`/auth/login`, `{"username":"e2euser","password":"e2e-pass-123"}`)
  292. var l1b struct {
  293. LoginTicket string `json:"loginTicket"`
  294. }
  295. _ = json.Unmarshal(step1b.Data, &l1b)
  296. if scope := a.post(`/auth/issue`, `{"loginTicket":"`+l1b.LoginTicket+`","institutionId":99,"campusId":99}`); scope.Code != 1003 {
  297. t.Fatalf("越权 issue code=%d(期望 1003 作用域越权)", scope.Code)
  298. }
  299. }
  300. // TestLoginE2E_BadPassword 真库错密:code 1001(防枚举统一文案)。
  301. //
  302. // 注意:密码必须**长度合法(≥6,过 validate min=6)**但错误——否则会在校验层被拦成 2001,
  303. // 根本走不到"防枚举 1001 统一文案"路径(本测试要验证的是后者)。用与真实密码不同的合法长度串。
  304. func TestLoginE2E_BadPassword(t *testing.T) {
  305. a := e2eSetup(t)
  306. a.seedUser("e2euser", "e2e-pass-123", 11, 3, "teacher")
  307. res := a.post(`/auth/login`, `{"username":"e2euser","password":"wrong-pass-999"}`)
  308. if res.Code != 1001 {
  309. t.Fatalf("code=%d(期望 1001 统一文案)", res.Code)
  310. }
  311. }
  312. // seedWechatUser 落一个用户 + wechat 身份(type=wechat, identifier=openid)+ 一条 membership(raw SQL)。
  313. // 与 seedUser 的差异:无密码哈希(微信登录不验密)、身份类型为 wechat(扫码绑定的 openid)。
  314. func (a *e2eApp) seedWechatUser(openid string, inst, campus int64, role string) string {
  315. a.t.Helper()
  316. uid, err := idpkg.NewCanonicalUserID()
  317. if err != nil {
  318. a.t.Fatalf("生成 canonical user id: %v", err)
  319. }
  320. ctx := context.Background()
  321. now := time.Now()
  322. if err := a.gdb.WithContext(ctx).Create(&model.User{
  323. CanonicalUserID: uid, PersonType: model.PersonTypeStaff,
  324. Status: model.UserStatusActive, CreatedAt: now, UpdatedAt: now,
  325. }).Error; err != nil {
  326. a.t.Fatalf("插入 t_user: %v", err)
  327. }
  328. if err := a.gdb.WithContext(ctx).Create(&model.Identity{
  329. CanonicalUserID: uid, Type: model.IdentityTypeWechat, Identifier: openid,
  330. Verified: true, CreatedAt: now,
  331. }).Error; err != nil {
  332. a.t.Fatalf("插入 t_identity(wechat): %v", err)
  333. }
  334. if err := a.gdb.WithContext(ctx).Exec(
  335. `INSERT INTO t_membership (canonical_user_id, institution_id, campus_id, role, status, joined_at, created_at)
  336. VALUES (?, ?, ?, ?, 'active', ?, ?)`,
  337. uid, inst, campus, role, now, now,
  338. ).Error; err != nil {
  339. a.t.Fatalf("插入 t_membership: %v", err)
  340. }
  341. return uid
  342. }
  343. // TestWechatE2E 微信扫码登录全链路(真库):qrcode → callback(code→openid 真查 t_identity) → success+loginTicket
  344. // → 复用同一套 ② issue 签 token。验证"微信扫码与账密登录共用两步②"的核心契约。
  345. func TestWechatE2E(t *testing.T) {
  346. a := e2eSetup(t)
  347. uid := a.seedWechatUser("openid-e2e", 11, 3, "teacher")
  348. a.wechat.byCode["code-e2e"] = "openid-e2e" // 打桩:code→openid 映射
  349. // ① qrcode:200 + state
  350. qrEnv := a.get(`/auth/wechat/qrcode`)
  351. if qrEnv.Code != 200 {
  352. t.Fatalf("qrcode code=%d msg=%s(期望 200)", qrEnv.Code, qrEnv.Message)
  353. }
  354. var qr struct {
  355. State string `json:"state"`
  356. }
  357. if err := json.Unmarshal(qrEnv.Data, &qr); err != nil {
  358. t.Fatalf("解析 qrcode data: %v", err)
  359. }
  360. if qr.State == "" {
  361. t.Fatal("state 缺失")
  362. }
  363. // ② callback:code 换 openid(打桩)→ 真查 t_identity(wechat) → 已绑定 → success + loginTicket
  364. cbEnv := a.get(`/auth/wechat/callback?code=code-e2e&state=` + qr.State)
  365. if cbEnv.Code != 200 {
  366. t.Fatalf("callback code=%d msg=%s(期望 200 成功)", cbEnv.Code, cbEnv.Message)
  367. }
  368. var cb struct {
  369. Status string `json:"status"`
  370. LoginTicket string `json:"loginTicket"`
  371. UserID string `json:"userId"`
  372. }
  373. if err := json.Unmarshal(cbEnv.Data, &cb); err != nil {
  374. t.Fatalf("解析 callback data: %v", err)
  375. }
  376. if cb.Status != "success" || cb.UserID != uid || cb.LoginTicket == "" {
  377. t.Fatalf("callback=%+v(期望 success + userId=%q + loginTicket)", cb, uid)
  378. }
  379. // ③ 复用两步②:携 loginTicket 签 token(证明微信登录与账密登录走同一套 ②)
  380. issueRes := a.post(`/auth/issue`, `{"loginTicket":"`+cb.LoginTicket+`","institutionId":11,"campusId":3}`)
  381. if issueRes.Code != 200 {
  382. t.Fatalf("issue code=%d msg=%s(期望 200:微信票据应可走同一套 ②)", issueRes.Code, issueRes.Message)
  383. }
  384. var pair struct {
  385. AccessToken string `json:"accessToken"`
  386. Roles []string `json:"roles"`
  387. }
  388. if err := json.Unmarshal(issueRes.Data, &pair); err != nil {
  389. t.Fatalf("解析 issue data: %v", err)
  390. }
  391. if pair.AccessToken == "" {
  392. t.Fatal("accessToken 缺失")
  393. }
  394. if len(pair.Roles) != 1 || pair.Roles[0] != "teacher" {
  395. t.Fatalf("roles=%v(期望 [teacher])", pair.Roles)
  396. }
  397. // access 可被本公钥验签 + claims 正确
  398. claims, err := token.Verify(context.Background(), a.pubKeys, a.revocation, "https://unified.test", pair.AccessToken)
  399. if err != nil {
  400. t.Fatalf("验签 access 失败: %v", err)
  401. }
  402. if claims.Sub != uid || claims.InstitutionID != 11 || claims.CampusID != 3 {
  403. t.Fatalf("claims=%+v(期望 %q/11/3)", claims, uid)
  404. }
  405. // ④ 重放 callback(已终态)→ 1001(防重放)
  406. if replay := a.get(`/auth/wechat/callback?code=code-e2e&state=` + qr.State); replay.Code != 1001 {
  407. t.Fatalf("重放 callback code=%d(期望 1001 已终态)", replay.Code)
  408. }
  409. }
  410. // TestWechatE2E_Unbound 真库未绑定 openid:callback → unbound(引导去账密登录后绑定)。
  411. func TestWechatE2E_Unbound(t *testing.T) {
  412. a := e2eSetup(t)
  413. a.seedWechatUser("openid-other", 11, 3, "teacher") // 造一个已绑定用户(保证表/数据存在)
  414. a.wechat.byCode["code-x"] = "openid-not-bound" // 该 openid 无身份记录
  415. qrEnv := a.get(`/auth/wechat/qrcode`)
  416. var qr struct{ State string `json:"state"` }
  417. _ = json.Unmarshal(qrEnv.Data, &qr)
  418. cbEnv := a.get(`/auth/wechat/callback?code=code-x&state=` + qr.State)
  419. if cbEnv.Code != 200 {
  420. t.Fatalf("callback code=%d(期望 200 unbound 语义)", cbEnv.Code)
  421. }
  422. var cb struct {
  423. Status string `json:"status"`
  424. }
  425. _ = json.Unmarshal(cbEnv.Data, &cb)
  426. if cb.Status != "unbound" {
  427. t.Fatalf("status=%q(期望 unbound)", cb.Status)
  428. }
  429. }