mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-01 04:21:36 +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"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/goharbor/harbor/src/lib/q"
|
||||||
|
|
||||||
"github.com/goharbor/harbor/src/pkg/p2p/preheat/provider/auth"
|
"github.com/goharbor/harbor/src/pkg/p2p/preheat/provider/auth"
|
||||||
|
|
||||||
"github.com/goharbor/harbor/src/core/config"
|
"github.com/goharbor/harbor/src/core/config"
|
||||||
@ -66,7 +68,9 @@ func (s *preheatSuite) SetupSuite() {
|
|||||||
},
|
},
|
||||||
}, nil)
|
}, nil)
|
||||||
s.fakeInstanceMgr.On("Save", mock.Anything, mock.Anything).Return(int64(1), 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("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(1)).Return(nil)
|
||||||
s.fakeInstanceMgr.On("Delete", mock.Anything, int64(0)).Return(errors.New("not found"))
|
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:
|
case pol.FilterTypeVulnerability:
|
||||||
if v, ok := pro.Metadata[proMetaKeyVulnerability]; ok && v == "true" {
|
if v, ok := pro.Metadata[proMetaKeyVulnerability]; ok && v == "true" {
|
||||||
if se, ok := pro.Metadata[proMetaKeySeverity]; ok && len(se) > 0 {
|
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()
|
code := vuln.Severity(se).Code()
|
||||||
|
|
||||||
if sev, ok := fl.Value.(int); !ok || (ok && sev < code) {
|
if sev, ok := fl.Value.(int); !ok || (ok && sev < code) {
|
||||||
|
Loading…
Reference in New Issue
Block a user