Download this file
| 1 | package console |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "time" |
| 6 | |
| 7 | "github.com/carlosframework/platform/internal/svcrole" |
| 8 | ) |
| 9 | |
| 10 | // serviceToken mints a service principal and returns its bearer — the |
| 11 | // service-principal counterpart of cliToken, and deliberately the same |
| 12 | // shape, so a test reads the same whichever kind of caller it is exercising. |
| 13 | // Tasks 4-8 use this; do not invent a second one. |
| 14 | func serviceToken(t *testing.T, st *Store, accountID int64, name, app string, role svcrole.Role) string { |
| 15 | t.Helper() |
| 16 | raw, err := st.NewServicePrincipal(accountID, name, app, role, "paul@example.test", time.Now()) |
| 17 | if err != nil { |
| 18 | t.Fatalf("NewServicePrincipal(%q): %v", name, err) |
| 19 | } |
| 20 | return raw |
| 21 | } |
| 22 | |