[feature] Application creation + management via API + settings panel (#3906)

* [feature] Application creation + management via API + settings panel

* fix docs links

* add errnorows test

* use known application as shorter

* add comment about side effects
This commit is contained in:
tobi 2025-03-17 15:06:17 +01:00 committed by GitHub
commit d5847e2d2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 3036 additions and 252 deletions

View file

@ -92,7 +92,7 @@ func (suite *ApplicationTestSuite) TestDeleteApplicationBy() {
for _, app := range suite.testApplications {
for lookup, dbfunc := range map[string]func() error{
"client_id": func() error {
return suite.db.DeleteApplicationByClientID(ctx, app.ClientID)
return suite.db.DeleteApplicationByID(ctx, app.ID)
},
} {
// Clear database caches.
@ -124,6 +124,36 @@ func (suite *ApplicationTestSuite) TestGetAllTokens() {
suite.NotEmpty(tokens)
}
func (suite *ApplicationTestSuite) TestDeleteTokensByClientID() {
ctx := context.Background()
// Delete tokens by each app.
for _, app := range suite.testApplications {
if err := suite.state.DB.DeleteTokensByClientID(ctx, app.ClientID); err != nil {
suite.FailNow(err.Error())
}
}
// Ensure all tokens deleted.
for _, token := range suite.testTokens {
_, err := suite.db.GetTokenByID(ctx, token.ID)
if !errors.Is(err, db.ErrNoEntries) {
suite.FailNow("", "token %s not deleted", token.ID)
}
}
}
func (suite *ApplicationTestSuite) TestDeleteTokensByUnknownClientID() {
// Should not return ErrNoRows even though
// the client with given ID doesn't exist.
if err := suite.state.DB.DeleteTokensByClientID(
context.Background(),
"01JPJ4NCGH6GHY7ZVYBHNP55XS",
); err != nil {
suite.FailNow(err.Error())
}
}
func TestApplicationTestSuite(t *testing.T) {
suite.Run(t, new(ApplicationTestSuite))
}