mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-04 23:54:03 -04:00
feat(storage-users): add virusfilter to sessions command
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
5
changelog/unreleased/add-virus-filter.md
Normal file
5
changelog/unreleased/add-virus-filter.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Enhancement: Add virus filter to sessions command
|
||||
|
||||
Allow filtering upload session by virus status (has-virus=true/false)
|
||||
|
||||
https://github.com/owncloud/ocis/pull/9041
|
||||
@@ -119,6 +119,11 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
DefaultText: "unset",
|
||||
Usage: "filter sessions by expired status",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "has-virus",
|
||||
DefaultText: "unset",
|
||||
Usage: "filter sessions by virus scan result",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "json",
|
||||
Usage: "output as json",
|
||||
@@ -320,6 +325,10 @@ func buildFilter(c *cli.Context) storage.UploadSessionFilter {
|
||||
expiredValue := c.Bool("expired")
|
||||
filter.Expired = &expiredValue
|
||||
}
|
||||
if c.IsSet("has-virus") {
|
||||
infectedValue := c.Bool("has-virus")
|
||||
filter.HasVirus = &infectedValue
|
||||
}
|
||||
if c.IsSet("id") {
|
||||
idValue := c.String("id")
|
||||
filter.ID = &idValue
|
||||
@@ -358,6 +367,24 @@ func buildInfo(filter storage.UploadSessionFilter) string {
|
||||
}
|
||||
}
|
||||
|
||||
if filter.HasVirus != nil {
|
||||
if b.Len() != 0 {
|
||||
b.WriteString(", ")
|
||||
}
|
||||
if !*filter.HasVirus {
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Not ")
|
||||
} else {
|
||||
b.WriteString("not ")
|
||||
}
|
||||
}
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Virusinfected")
|
||||
} else {
|
||||
b.WriteString("virusinfected")
|
||||
}
|
||||
}
|
||||
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Session")
|
||||
} else {
|
||||
|
||||
@@ -38,6 +38,31 @@ func TestBuildInfo(t *testing.T) {
|
||||
filter: storage.UploadSessionFilter{ID: strPtr("123")},
|
||||
expectedInfo: "Session with id '123':",
|
||||
},
|
||||
{
|
||||
alias: "processing, not expired and not virus infected",
|
||||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false), HasVirus: boolPtr(false)},
|
||||
expectedInfo: "Processing, not expired, not virusinfected sessions:",
|
||||
},
|
||||
{
|
||||
alias: "not virusinfected",
|
||||
filter: storage.UploadSessionFilter{HasVirus: boolPtr(false)},
|
||||
expectedInfo: "Not virusinfected sessions:",
|
||||
},
|
||||
{
|
||||
alias: "expired and virusinfected",
|
||||
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(true)},
|
||||
expectedInfo: "Expired, virusinfected sessions:",
|
||||
},
|
||||
{
|
||||
alias: "expired and not virus infected",
|
||||
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(false)},
|
||||
expectedInfo: "Expired, not virusinfected sessions:",
|
||||
},
|
||||
{
|
||||
alias: "processing, not expired, virus infected and with id (note: this makes no sense)",
|
||||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false), HasVirus: boolPtr(true), ID: strPtr("123")},
|
||||
expectedInfo: "Processing, not expired, virusinfected session with id '123':",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user