Mm 30807 granular data retention scaffold (#16891)

create the necessary tables, models and APIs for the granular data retention policy feature
Этот коммит содержится в:
Max Erenberg
2021-04-16 11:32:09 -04:00
коммит произвёл GitHub
родитель 03473f98ac
Коммит 3ea75332e7
49 изменённых файлов: 5079 добавлений и 984 удалений

Просмотреть файл

@@ -1025,6 +1025,62 @@ func TestGetAllChannels(t *testing.T) {
_, resp := Client.GetAllChannels(0, 20, "")
CheckForbiddenStatus(t, resp)
sysManagerChannels, resp := th.SystemManagerClient.GetAllChannels(0, 10000, "")
CheckOKStatus(t, resp)
policyChannel := (*sysManagerChannels)[0]
policy, savePolicyErr := th.App.Srv().Store.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDuration: model.NewInt64(30),
},
ChannelIDs: []string{policyChannel.Id},
})
require.NoError(t, savePolicyErr)
t.Run("exclude policy constrained", func(t *testing.T) {
_, resp := th.SystemManagerClient.GetAllChannelsExcludePolicyConstrained(0, 10000, "")
CheckForbiddenStatus(t, resp)
channels, resp := th.SystemAdminClient.GetAllChannelsExcludePolicyConstrained(0, 10000, "")
CheckOKStatus(t, resp)
found := false
for _, channel := range *channels {
if channel.Id == policyChannel.Id {
found = true
break
}
}
require.False(t, found)
})
t.Run("does not return policy ID", func(t *testing.T) {
channels, resp := th.SystemManagerClient.GetAllChannels(0, 10000, "")
CheckOKStatus(t, resp)
found := false
for _, channel := range *channels {
if channel.Id == policyChannel.Id {
found = true
require.Nil(t, channel.PolicyID)
break
}
}
require.True(t, found)
})
t.Run("returns policy ID", func(t *testing.T) {
channels, resp := th.SystemAdminClient.GetAllChannels(0, 10000, "")
CheckOKStatus(t, resp)
found := false
for _, channel := range *channels {
if channel.Id == policyChannel.Id {
found = true
require.Equal(t, *channel.PolicyID, policy.ID)
break
}
}
require.True(t, found)
})
}
func TestGetAllChannelsWithCount(t *testing.T) {
@@ -1390,6 +1446,46 @@ func TestSearchAllChannels(t *testing.T) {
_, resp = Client.SearchAllChannels(&model.ChannelSearch{Term: ""})
CheckForbiddenStatus(t, resp)
// Choose a policy which the system manager can read
sysManagerChannels, resp := th.SystemManagerClient.GetAllChannels(0, 10000, "")
CheckOKStatus(t, resp)
policyChannel := (*sysManagerChannels)[0]
policy, savePolicyErr := th.App.Srv().Store.RetentionPolicy().Save(&model.RetentionPolicyWithTeamAndChannelIDs{
RetentionPolicy: model.RetentionPolicy{
DisplayName: "Policy 1",
PostDuration: model.NewInt64(30),
},
ChannelIDs: []string{policyChannel.Id},
})
require.NoError(t, savePolicyErr)
t.Run("does not return policy ID", func(t *testing.T) {
channels, resp := th.SystemManagerClient.SearchAllChannels(&model.ChannelSearch{Term: policyChannel.Name})
CheckOKStatus(t, resp)
found := false
for _, channel := range *channels {
if channel.Id == policyChannel.Id {
found = true
require.Nil(t, channel.PolicyID)
break
}
}
require.True(t, found)
})
t.Run("returns policy ID", func(t *testing.T) {
channels, resp := th.SystemAdminClient.SearchAllChannels(&model.ChannelSearch{Term: policyChannel.Name})
CheckOKStatus(t, resp)
found := false
for _, channel := range *channels {
if channel.Id == policyChannel.Id {
found = true
require.Equal(t, *channel.PolicyID, policy.ID)
break
}
}
require.True(t, found)
})
}
func TestSearchAllChannelsPaged(t *testing.T) {