(t *testing.T)
| 173 | } |
| 174 | |
| 175 | func TestCreateAPIKey(t *testing.T) { |
| 176 | pool := testutil.TestDB(t) |
| 177 | store := identity.NewStore(pool) |
| 178 | ctx := context.Background() |
| 179 | |
| 180 | user, err := store.CreateOrGetUser(ctx, "apikey-owner@example.com", "Owner", "google-apikey-create") |
| 181 | if err != nil { |
| 182 | t.Fatalf("CreateOrGetUser: %v", err) |
| 183 | } |
| 184 | |
| 185 | key, err := store.CreateAPIKey(ctx, user.ID, "test key", nil) |
| 186 | if err != nil { |
| 187 | t.Fatalf("CreateAPIKey: %v", err) |
| 188 | } |
| 189 | if !strings.HasPrefix(key.ID, "apk_") { |
| 190 | t.Errorf("ID should start with apk_, got %q", key.ID) |
| 191 | } |
| 192 | if !strings.HasPrefix(key.PlaintextKey, "e2a_") { |
| 193 | t.Errorf("PlaintextKey should start with e2a_, got %q", key.PlaintextKey) |
| 194 | } |
| 195 | if key.UserID != user.ID { |
| 196 | t.Errorf("UserID = %q, want %q", key.UserID, user.ID) |
| 197 | } |
| 198 | if key.Name != "test key" { |
| 199 | t.Errorf("Name = %q, want %q", key.Name, "test key") |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | func TestListAPIKeys(t *testing.T) { |
| 204 | pool := testutil.TestDB(t) |
nothing calls this directly
no test coverage detected