[SEC] Notify owner about TOTP enrollment

- In the spirit of #4635
- Notify the owner when their account is getting enrolled into TOTP. The
message is changed according if they have security keys or not.
- Integration test added.
This commit is contained in:
Gusted 2024-07-26 19:26:44 +02:00
parent 2285526e93
commit a7e96aae66
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 137 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models/db"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"xorm.io/builder"
)
@ -130,6 +131,12 @@ func AssertSuccessfulInsert(t assert.TestingT, beans ...any) {
assert.NoError(t, err)
}
// AssertSuccessfulDelete assert that beans is successfully deleted
func AssertSuccessfulDelete(t require.TestingT, beans ...any) {
err := db.DeleteBeans(db.DefaultContext, beans...)
require.NoError(t, err)
}
// AssertCount assert the count of a bean
func AssertCount(t assert.TestingT, bean, expected any) bool {
return assert.EqualValues(t, expected, GetCount(t, bean))