Fix public boards setting not applying properly. (#22921)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2dafc51be2
Коммит
8c73f092e8
@@ -58,6 +58,10 @@ func (a *Auth) IsValidReadToken(boardID string, readToken string) (bool, error)
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !a.config.EnablePublicSharedBoards {
|
||||||
|
return false, errors.New("public shared boards disabled")
|
||||||
|
}
|
||||||
|
|
||||||
if sharing != nil && (sharing.ID == boardID && sharing.Enabled && sharing.Token == readToken) {
|
if sharing != nil && (sharing.ID == boardID && sharing.Enabled && sharing.Token == readToken) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -585,6 +585,35 @@ func TestPermissionsGetBoard(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPermissionsGetBoardPublic(t *testing.T) {
|
||||||
|
ttCases := []TestCase{
|
||||||
|
{"/boards/{PRIVATE_BOARD_ID}?read_token=invalid", methodGet, "", userAnon, http.StatusUnauthorized, 0},
|
||||||
|
{"/boards/{PRIVATE_BOARD_ID}?read_token=valid", methodGet, "", userAnon, http.StatusUnauthorized, 1},
|
||||||
|
{"/boards/{PRIVATE_BOARD_ID}?read_token=invalid", methodGet, "", userNoTeamMember, http.StatusForbidden, 0},
|
||||||
|
{"/boards/{PRIVATE_BOARD_ID}?read_token=valid", methodGet, "", userTeamMember, http.StatusForbidden, 1},
|
||||||
|
}
|
||||||
|
t.Run("plugin", func(t *testing.T) {
|
||||||
|
th := SetupTestHelperPluginMode(t)
|
||||||
|
defer th.TearDown()
|
||||||
|
cfg := th.Server.Config()
|
||||||
|
cfg.EnablePublicSharedBoards = false
|
||||||
|
th.Server.UpdateAppConfig()
|
||||||
|
clients := setupClients(th)
|
||||||
|
testData := setupData(t, th)
|
||||||
|
runTestCases(t, ttCases, testData, clients)
|
||||||
|
})
|
||||||
|
t.Run("local", func(t *testing.T) {
|
||||||
|
th := SetupTestHelperLocalMode(t)
|
||||||
|
defer th.TearDown()
|
||||||
|
cfg := th.Server.Config()
|
||||||
|
cfg.EnablePublicSharedBoards = false
|
||||||
|
th.Server.UpdateAppConfig()
|
||||||
|
clients := setupLocalClients(th)
|
||||||
|
testData := setupData(t, th)
|
||||||
|
runTestCases(t, ttCases, testData, clients)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestPermissionsPatchBoard(t *testing.T) {
|
func TestPermissionsPatchBoard(t *testing.T) {
|
||||||
ttCases := []TestCase{
|
ttCases := []TestCase{
|
||||||
{"/boards/{PRIVATE_BOARD_ID}", methodPatch, "{\"title\": \"test\"}", userAnon, http.StatusUnauthorized, 0},
|
{"/boards/{PRIVATE_BOARD_ID}", methodPatch, "{\"title\": \"test\"}", userAnon, http.StatusUnauthorized, 0},
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user