mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-17 14:00:01 +02:00
Move more model into models/user (#17826)
* Move more model into models/user * Remove unnecessary comment Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
b1df890951
commit
9defddb286
23 changed files with 547 additions and 603 deletions
|
@ -64,32 +64,5 @@ func testUserListIsUserOrgOwner(t *testing.T, orgID int64, expected map[int64]bo
|
|||
assert.NoError(t, err)
|
||||
members, _, err := org.GetMembers()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected, members.IsUserOrgOwner(orgID))
|
||||
}
|
||||
|
||||
func TestUserListIsTwoFaEnrolled(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
tt := []struct {
|
||||
orgid int64
|
||||
expected map[int64]bool
|
||||
}{
|
||||
{3, map[int64]bool{2: false, 4: false, 28: false}},
|
||||
{6, map[int64]bool{5: false, 28: false}},
|
||||
{7, map[int64]bool{5: false}},
|
||||
{25, map[int64]bool{24: true}},
|
||||
{22, map[int64]bool{}},
|
||||
}
|
||||
for _, v := range tt {
|
||||
t.Run(fmt.Sprintf("IsTwoFaEnrolledOfOrdIg%d", v.orgid), func(t *testing.T) {
|
||||
testUserListIsTwoFaEnrolled(t, v.orgid, v.expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testUserListIsTwoFaEnrolled(t *testing.T, orgID int64, expected map[int64]bool) {
|
||||
org, err := GetOrgByID(orgID)
|
||||
assert.NoError(t, err)
|
||||
members, _, err := org.GetMembers()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected, members.GetTwoFaStatus())
|
||||
assert.Equal(t, expected, IsUserOrgOwner(members, orgID))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue