(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestExtractAccessToken(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | metadata map[string]any |
| 19 | expected string |
| 20 | }{ |
| 21 | { |
| 22 | "antigravity top-level access_token", |
| 23 | map[string]any{"access_token": "tok-abc"}, |
| 24 | "tok-abc", |
| 25 | }, |
| 26 | { |
| 27 | "gemini nested token.access_token", |
| 28 | map[string]any{ |
| 29 | "token": map[string]any{"access_token": "tok-nested"}, |
| 30 | }, |
| 31 | "tok-nested", |
| 32 | }, |
| 33 | { |
| 34 | "top-level takes precedence over nested", |
| 35 | map[string]any{ |
| 36 | "access_token": "tok-top", |
| 37 | "token": map[string]any{"access_token": "tok-nested"}, |
| 38 | }, |
| 39 | "tok-top", |
| 40 | }, |
| 41 | { |
| 42 | "empty metadata", |
| 43 | map[string]any{}, |
| 44 | "", |
| 45 | }, |
| 46 | { |
| 47 | "whitespace-only access_token", |
| 48 | map[string]any{"access_token": " "}, |
| 49 | "", |
| 50 | }, |
| 51 | { |
| 52 | "wrong type access_token", |
| 53 | map[string]any{"access_token": 12345}, |
| 54 | "", |
| 55 | }, |
| 56 | { |
| 57 | "token is not a map", |
| 58 | map[string]any{"token": "not-a-map"}, |
| 59 | "", |
| 60 | }, |
| 61 | { |
| 62 | "nested whitespace-only", |
| 63 | map[string]any{ |
| 64 | "token": map[string]any{"access_token": " "}, |
| 65 | }, |
| 66 | "", |
| 67 | }, |
| 68 | { |
| 69 | "fallback to nested when top-level empty", |
| 70 | map[string]any{ |
nothing calls this directly
no test coverage detected