MM-63791: guest permissions to teams (#30789)
* improve th.CreateGuestAndClient * test coverage for guest user access to teams * restrict guest access to public teams unless a member
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
79561c44c2
Коммит
701ddc896a
@@ -695,7 +695,8 @@ func (th *TestHelper) CreateUserWithAuth(authService string) *model.User {
|
||||
// CreateGuestAndClient creates a guest user, adds them to the basic
|
||||
// team, basic channel and basic private channel, and generates an API
|
||||
// client ready to use
|
||||
func (th *TestHelper) CreateGuestAndClient() (*model.User, *model.Client4) {
|
||||
func (th *TestHelper) CreateGuestAndClient(tb testing.TB) (*model.User, *model.Client4) {
|
||||
tb.Helper()
|
||||
id := model.NewId()
|
||||
|
||||
// create a guest user and add it to the basic team and public/private channels
|
||||
@@ -706,23 +707,17 @@ func (th *TestHelper) CreateGuestAndClient() (*model.User, *model.Client4) {
|
||||
Password: "Password1",
|
||||
EmailVerified: true,
|
||||
})
|
||||
if cgErr != nil {
|
||||
panic(cgErr)
|
||||
}
|
||||
require.Nil(tb, cgErr)
|
||||
|
||||
_, _, tErr := th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, guest.Id, th.SystemAdminUser.Id)
|
||||
if tErr != nil {
|
||||
panic(tErr)
|
||||
}
|
||||
_, _, appErr := th.App.AddUserToTeam(th.Context, th.BasicTeam.Id, guest.Id, th.SystemAdminUser.Id)
|
||||
require.Nil(tb, appErr)
|
||||
th.AddUserToChannel(guest, th.BasicChannel)
|
||||
th.AddUserToChannel(guest, th.BasicPrivateChannel)
|
||||
|
||||
// create a client and login the guest
|
||||
guestClient := th.CreateClient()
|
||||
_, _, lErr := guestClient.Login(context.Background(), guest.Username, "Password1")
|
||||
if lErr != nil {
|
||||
panic(lErr)
|
||||
}
|
||||
_, _, err := guestClient.Login(context.Background(), guest.Email, "Password1")
|
||||
require.NoError(tb, err)
|
||||
|
||||
return guest, guestClient
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user