mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-20 06:31:55 +01:00
fix(preheat):fix ctl ut failure case
Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
parent
6b9e0e66c4
commit
144edcc0c4
@ -7,6 +7,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/lib/q"
|
||||
|
||||
"github.com/goharbor/harbor/src/pkg/p2p/preheat/provider/auth"
|
||||
|
||||
"github.com/goharbor/harbor/src/core/config"
|
||||
@ -66,7 +68,9 @@ func (s *preheatSuite) SetupSuite() {
|
||||
},
|
||||
}, nil)
|
||||
s.fakeInstanceMgr.On("Save", mock.Anything, mock.Anything).Return(int64(1), nil)
|
||||
s.fakeInstanceMgr.On("Count", mock.Anything, &providerModel.Instance{Endpoint: "http://localhost"}).Return(int64(1), nil)
|
||||
s.fakeInstanceMgr.On("Count", mock.Anything, &q.Query{Keywords: map[string]interface{}{
|
||||
"endpoint": "http://localhost",
|
||||
}}).Return(int64(1), nil)
|
||||
s.fakeInstanceMgr.On("Count", mock.Anything, mock.Anything).Return(int64(0), nil)
|
||||
s.fakeInstanceMgr.On("Delete", mock.Anything, int64(1)).Return(nil)
|
||||
s.fakeInstanceMgr.On("Delete", mock.Anything, int64(0)).Return(errors.New("not found"))
|
||||
|
@ -603,7 +603,7 @@ func overrideSecuritySettings(p *pol.Schema, pro *models.Project) [][]interface{
|
||||
case pol.FilterTypeVulnerability:
|
||||
if v, ok := pro.Metadata[proMetaKeyVulnerability]; ok && v == "true" {
|
||||
if se, ok := pro.Metadata[proMetaKeySeverity]; ok && len(se) > 0 {
|
||||
se = strings.ToTitle(strings.ToLower(se))
|
||||
se = strings.Title(strings.ToLower(se))
|
||||
code := vuln.Severity(se).Code()
|
||||
|
||||
if sev, ok := fl.Value.(int); !ok || (ok && sev < code) {
|
||||
|
Loading…
Reference in New Issue
Block a user