mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 10:15:35 +01:00
Merge pull request #5751 from wy65701436/fix-gofmt
Fix gofmt check results
This commit is contained in:
commit
925f70a1ac
@ -26,9 +26,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/adminserver/systemcfg"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type fakeCfgStore struct {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Ping monitor the server status
|
||||
|
@ -1,16 +1,17 @@
|
||||
package api
|
||||
import(
|
||||
"testing"
|
||||
"net/http/httptest"
|
||||
"net/http"
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPing(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
Ping(w, nil)
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
result, _:= ioutil.ReadAll(w.Body)
|
||||
result, _ := ioutil.ReadAll(w.Body)
|
||||
assert.Equal(t, "\"Pong\"", string(result))
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/adminserver/systeminfo/imagestorage"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type fakeImageStorageDriver struct {
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
commonsecret "github.com/goharbor/harbor/src/common/secret"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAuthenticate(t *testing.T) {
|
||||
|
@ -19,9 +19,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var c Client
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
gorilla_handlers "github.com/gorilla/handlers"
|
||||
"github.com/goharbor/harbor/src/adminserver/auth"
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
gorilla_handlers "github.com/gorilla/handlers"
|
||||
)
|
||||
|
||||
// NewHandler returns a gorilla router which is wrapped by authenticate handler
|
||||
@ -32,7 +32,7 @@ func NewHandler() http.Handler {
|
||||
"jobserviceSecret": os.Getenv("JOBSERVICE_SECRET"),
|
||||
}
|
||||
insecureAPIs := map[string]bool{
|
||||
"/api/ping":true,
|
||||
"/api/ping": true,
|
||||
}
|
||||
h = newAuthHandler(auth.NewSecretAuthenticator(secrets), h, insecureAPIs)
|
||||
h = gorilla_handlers.LoggingHandler(os.Stdout, h)
|
||||
@ -49,7 +49,7 @@ func newAuthHandler(authenticator auth.Authenticator, handler http.Handler, inse
|
||||
return &authHandler{
|
||||
authenticator: authenticator,
|
||||
handler: handler,
|
||||
insecureAPIs: insecureAPIs,
|
||||
insecureAPIs: insecureAPIs,
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ func (a *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if a.insecureAPIs !=nil && a.insecureAPIs[r.URL.Path] {
|
||||
if a.insecureAPIs != nil && a.insecureAPIs[r.URL.Path] {
|
||||
if a.handler != nil {
|
||||
a.handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/adminserver/auth"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type fakeAuthenticator struct {
|
||||
@ -50,35 +50,35 @@ func TestNewAuthHandler(t *testing.T) {
|
||||
requestURL string
|
||||
}{
|
||||
|
||||
{nil, nil, nil, http.StatusOK,"http://localhost/good"},
|
||||
{nil, nil, nil, http.StatusOK, "http://localhost/good"},
|
||||
{&fakeAuthenticator{
|
||||
authenticated: false,
|
||||
err: nil,
|
||||
}, nil, nil, http.StatusUnauthorized,"http://localhost/hello"},
|
||||
}, nil, nil, http.StatusUnauthorized, "http://localhost/hello"},
|
||||
{&fakeAuthenticator{
|
||||
authenticated: false,
|
||||
err: errors.New("error"),
|
||||
}, nil, nil, http.StatusInternalServerError,"http://localhost/hello"},
|
||||
}, nil, nil, http.StatusInternalServerError, "http://localhost/hello"},
|
||||
{&fakeAuthenticator{
|
||||
authenticated: true,
|
||||
err: nil,
|
||||
}, &fakeHandler{http.StatusNotFound}, nil, http.StatusNotFound,"http://localhost/notexsit"},
|
||||
}, &fakeHandler{http.StatusNotFound}, nil, http.StatusNotFound, "http://localhost/notexsit"},
|
||||
{&fakeAuthenticator{
|
||||
authenticated: false,
|
||||
err: nil,
|
||||
}, &fakeHandler{http.StatusOK},map[string]bool{"/api/ping":true,},http.StatusOK,"http://localhost/api/ping"},
|
||||
}, &fakeHandler{http.StatusOK}, map[string]bool{"/api/ping": true}, http.StatusOK, "http://localhost/api/ping"},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
handler := newAuthHandler(c.authenticator, c.handler, c.insecureAPIs)
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("GET",c.requestURL,nil)
|
||||
r := httptest.NewRequest("GET", c.requestURL, nil)
|
||||
handler.ServeHTTP(w, r)
|
||||
assert.Equal(t, c.responseCode, w.Code, "unexpected response code")
|
||||
}
|
||||
handler := NewHandler()
|
||||
w := httptest.NewRecorder()
|
||||
r := httptest.NewRequest("GET","http://localhost/api/ping",nil)
|
||||
handler.ServeHTTP(w,r)
|
||||
|
||||
r := httptest.NewRequest("GET", "http://localhost/api/ping", nil)
|
||||
handler.ServeHTTP(w, r)
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ package handlers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/goharbor/harbor/src/adminserver/api"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func newRouter() http.Handler {
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
comcfg "github.com/goharbor/harbor/src/common/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type fakeKeyProvider struct {
|
||||
|
@ -3,9 +3,9 @@ package database
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCfgStore_Name(t *testing.T) {
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseStringToInt(t *testing.T) {
|
||||
|
@ -17,8 +17,8 @@ package filesystem
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
storage "github.com/goharbor/harbor/src/adminserver/systeminfo/imagestorage"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
|
@ -17,9 +17,9 @@ package dao
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
)
|
||||
|
||||
func TestAddAdminJob(t *testing.T) {
|
||||
|
@ -20,12 +20,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/utils"
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func execUpdate(o orm.Ormer, sql string, params ...interface{}) error {
|
||||
@ -1311,7 +1311,7 @@ func TestImgScanOverview(t *testing.T) {
|
||||
comp := &models.ComponentsOverview{
|
||||
Total: 2,
|
||||
Summary: []*models.ComponentsOverviewEntry{
|
||||
&models.ComponentsOverviewEntry{
|
||||
{
|
||||
Sev: int(models.SevMedium),
|
||||
Count: 2,
|
||||
},
|
||||
|
@ -251,17 +251,17 @@ func TestOnBoardUserGroup(t *testing.T) {
|
||||
|
||||
func TestGetGroupDNQueryCondition(t *testing.T) {
|
||||
userGroupList := []*models.UserGroup{
|
||||
&models.UserGroup{
|
||||
{
|
||||
GroupName: "sample1",
|
||||
GroupType: 1,
|
||||
LdapGroupDN: "cn=sample1_users,ou=groups,dc=example,dc=com",
|
||||
},
|
||||
&models.UserGroup{
|
||||
{
|
||||
GroupName: "sample2",
|
||||
GroupType: 1,
|
||||
LdapGroupDN: "cn=sample2_users,ou=groups,dc=example,dc=com",
|
||||
},
|
||||
&models.UserGroup{
|
||||
{
|
||||
GroupName: "sample3",
|
||||
GroupType: 0,
|
||||
LdapGroupDN: "cn=sample3_users,ou=groups,dc=example,dc=com",
|
||||
|
@ -23,9 +23,9 @@ import (
|
||||
_ "github.com/golang-migrate/migrate/database/postgres" //import pgsql driver for migrator
|
||||
_ "github.com/golang-migrate/migrate/source/file" // import local file driver for migrator
|
||||
|
||||
_ "github.com/lib/pq" //register pgsql driver
|
||||
"github.com/goharbor/harbor/src/common/utils"
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
_ "github.com/lib/pq" //register pgsql driver
|
||||
)
|
||||
|
||||
const defaultMigrationPath = "migrations/postgresql/"
|
||||
|
@ -17,9 +17,9 @@ package dao
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
)
|
||||
|
||||
func TestProMetaDaoMethods(t *testing.T) {
|
||||
|
@ -237,7 +237,7 @@ func TestGetProjectMember(t *testing.T) {
|
||||
t.Errorf("Error occurred when GetProjectByName: %v", err)
|
||||
}
|
||||
var memberList1 = []*models.Member{
|
||||
&models.Member{
|
||||
{
|
||||
ID: 346,
|
||||
Entityname: "admin",
|
||||
Rolename: "projectAdmin",
|
||||
@ -246,7 +246,7 @@ func TestGetProjectMember(t *testing.T) {
|
||||
EntityType: "u"},
|
||||
}
|
||||
var memberList2 = []*models.Member{
|
||||
&models.Member{
|
||||
{
|
||||
ID: 398,
|
||||
Entityname: "test_group_01",
|
||||
Rolename: "projectAdmin",
|
||||
|
@ -18,10 +18,10 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -17,10 +17,10 @@ package dao
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMethodsOfResourceLabel(t *testing.T) {
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDeleteUser(t *testing.T) {
|
||||
|
@ -17,9 +17,9 @@ package dao
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
)
|
||||
|
||||
func TestMethodsOfWatchItem(t *testing.T) {
|
||||
|
@ -17,9 +17,9 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
commonsecret "github.com/goharbor/harbor/src/common/secret"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
commonsecret "github.com/goharbor/harbor/src/common/secret"
|
||||
)
|
||||
|
||||
func TestAuthorizeOfSecretAuthorizer(t *testing.T) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package job
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/job/models"
|
||||
"github.com/goharbor/harbor/src/common/job/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
@ -41,7 +41,7 @@ func TestIsSysAdmin(t *testing.T) {
|
||||
func TestGetProjectRoles(t *testing.T) {
|
||||
ctx := &AuthContext{
|
||||
Projects: []*project{
|
||||
&project{
|
||||
{
|
||||
Name: "project",
|
||||
Roles: []string{projectAdminRole, developerRole, guestRole},
|
||||
Properties: map[string]string{"__projectIndex": "9"},
|
||||
@ -61,11 +61,11 @@ func TestGetProjectRoles(t *testing.T) {
|
||||
func TestGetMyProjects(t *testing.T) {
|
||||
ctx := &AuthContext{
|
||||
Projects: []*project{
|
||||
&project{
|
||||
{
|
||||
Name: "project1",
|
||||
Roles: []string{projectAdminRole},
|
||||
},
|
||||
&project{
|
||||
{
|
||||
Name: "project2",
|
||||
Roles: []string{developerRole},
|
||||
},
|
||||
|
@ -19,8 +19,6 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/dao/project"
|
||||
@ -28,6 +26,8 @@ import (
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
"github.com/goharbor/harbor/src/ui/promgr"
|
||||
"github.com/goharbor/harbor/src/ui/promgr/pmsdriver/local"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -283,7 +283,7 @@ func TestHasAllPermWithGroup(t *testing.T) {
|
||||
t.Errorf("Error occurred when GetUser: %v", err)
|
||||
}
|
||||
developer.GroupList = []*models.UserGroup{
|
||||
&models.UserGroup{GroupName: "test_group", GroupType: 1, LdapGroupDN: "cn=harbor_user,dc=example,dc=com"},
|
||||
{GroupName: "test_group", GroupType: 1, LdapGroupDN: "cn=harbor_user,dc=example,dc=com"},
|
||||
}
|
||||
ctx := NewSecurityContext(developer, pm)
|
||||
assert.False(t, ctx.HasAllPerm(project.Name))
|
||||
@ -360,7 +360,7 @@ func TestSecurityContext_GetRolesByGroup(t *testing.T) {
|
||||
t.Errorf("Error occurred when GetUser: %v", err)
|
||||
}
|
||||
developer.GroupList = []*models.UserGroup{
|
||||
&models.UserGroup{GroupName: "test_group", GroupType: 1, LdapGroupDN: "cn=harbor_user,dc=example,dc=com"},
|
||||
{GroupName: "test_group", GroupType: 1, LdapGroupDN: "cn=harbor_user,dc=example,dc=com"},
|
||||
}
|
||||
type fields struct {
|
||||
user *models.User
|
||||
|
@ -17,9 +17,9 @@ package secret
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/secret"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsAuthenticated(t *testing.T) {
|
||||
|
@ -17,9 +17,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/utils/clair/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestParseServerity(t *testing.T) {
|
||||
|
@ -304,7 +304,7 @@ func TestSession_SearchGroup(t *testing.T) {
|
||||
{"normal search",
|
||||
fields{ldapConfig: ldapConfig},
|
||||
args{baseDN: "dc=example,dc=com", filter: "objectClass=groupOfNames", groupName: "harbor_users", groupNameAttribute: "cn"},
|
||||
[]models.LdapGroup{models.LdapGroup{GroupName: "harbor_users", GroupDN: "cn=harbor_users,ou=groups,dc=example,dc=com"}}, false},
|
||||
[]models.LdapGroup{{GroupName: "harbor_users", GroupDN: "cn=harbor_users,ou=groups,dc=example,dc=com"}}, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
@ -358,7 +358,7 @@ func TestSession_SearchGroupByDN(t *testing.T) {
|
||||
{"normal search",
|
||||
fields{ldapConfig: ldapConfig, ldapGroupConfig: ldapGroupConfig},
|
||||
args{groupDN: "cn=harbor_users,ou=groups,dc=example,dc=com"},
|
||||
[]models.LdapGroup{models.LdapGroup{GroupName: "harbor_users", GroupDN: "cn=harbor_users,ou=groups,dc=example,dc=com"}}, false},
|
||||
[]models.LdapGroup{{GroupName: "harbor_users", GroupDN: "cn=harbor_users,ou=groups,dc=example,dc=com"}}, false},
|
||||
{"search non-exist group",
|
||||
fields{ldapConfig: ldapConfig, ldapGroupConfig: ldapGroupConfig},
|
||||
args{groupDN: "cn=harbor_non_users,ou=groups,dc=example,dc=com"},
|
||||
|
@ -78,7 +78,7 @@ func GetTargets(notaryEndpoint string, username string, fqRepo string) ([]Target
|
||||
res := []Target{}
|
||||
t, err := tokenutil.MakeToken(username, tokenutil.Notary,
|
||||
[]*token.ResourceActions{
|
||||
&token.ResourceActions{
|
||||
{
|
||||
Type: "repository",
|
||||
Name: fqRepo,
|
||||
Actions: []string{"pull"},
|
||||
|
@ -17,11 +17,11 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
notarytest "github.com/goharbor/harbor/src/common/utils/notary/test"
|
||||
utilstest "github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/ui/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
|
@ -23,10 +23,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/distribution/registry/auth/token"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFilterReq(t *testing.T) {
|
||||
|
@ -50,7 +50,7 @@ var (
|
||||
func TestBlobExist(t *testing.T) {
|
||||
handler := func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
dgt := path[strings.LastIndex(path, "/")+1 : len(path)]
|
||||
dgt := path[strings.LastIndex(path, "/")+1:]
|
||||
if dgt == digest {
|
||||
w.Header().Add(http.CanonicalHeaderKey("Content-Length"), strconv.Itoa(len(blob)))
|
||||
w.Header().Add(http.CanonicalHeaderKey("Docker-Content-Digest"), digest)
|
||||
@ -205,7 +205,7 @@ func TestDeleteBlob(t *testing.T) {
|
||||
func TestManifestExist(t *testing.T) {
|
||||
handler := func(w http.ResponseWriter, r *http.Request) {
|
||||
path := r.URL.Path
|
||||
tg := path[strings.LastIndex(path, "/")+1 : len(path)]
|
||||
tg := path[strings.LastIndex(path, "/")+1:]
|
||||
if tg == tag {
|
||||
w.Header().Add(http.CanonicalHeaderKey("Docker-Content-Digest"), digest)
|
||||
w.Header().Add(http.CanonicalHeaderKey("Content-Type"), mediaType)
|
||||
|
@ -2,8 +2,8 @@ package uaa
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/utils/uaa/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
|
@ -59,7 +59,7 @@ func (fc *FakeClient) SearchUser(name string) ([]*SearchUserEntry, error) {
|
||||
ExtID: "some-external-id-1",
|
||||
ID: "u-0001",
|
||||
UserName: "one",
|
||||
Emails: []SearchUserEmailEntry{SearchUserEmailEntry{
|
||||
Emails: []SearchUserEmailEntry{{
|
||||
Primary: false,
|
||||
Value: "one@email.com",
|
||||
}},
|
||||
@ -68,7 +68,7 @@ func (fc *FakeClient) SearchUser(name string) ([]*SearchUserEntry, error) {
|
||||
ExtID: "some-external-id-2-a",
|
||||
ID: "u-0002a",
|
||||
UserName: "two",
|
||||
Emails: []SearchUserEmailEntry{SearchUserEmailEntry{
|
||||
Emails: []SearchUserEmailEntry{{
|
||||
Primary: false,
|
||||
Value: "two@email.com",
|
||||
}},
|
||||
|
@ -424,7 +424,7 @@ func (fc *fakeController) CancelJob(jobID string) error {
|
||||
|
||||
func (fc *fakeController) CheckStatus() (models.JobPoolStats, error) {
|
||||
return models.JobPoolStats{
|
||||
Pools: []*models.JobPoolStatsData{&models.JobPoolStatsData{
|
||||
Pools: []*models.JobPoolStatsData{{
|
||||
WorkerPoolID: "fake_pool_ID",
|
||||
Status: "running",
|
||||
StartedAt: time.Now().Unix(),
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/goharbor/harbor/src/jobservice/errs"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -7,13 +7,13 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/robfig/cron"
|
||||
"github.com/goharbor/harbor/src/jobservice/config"
|
||||
"github.com/goharbor/harbor/src/jobservice/errs"
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/models"
|
||||
"github.com/goharbor/harbor/src/jobservice/pool"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -254,7 +254,7 @@ func (f *fakePool) PeriodicallyEnqueue(jobName string, params models.Parameters,
|
||||
func (f *fakePool) Stats() (models.JobPoolStats, error) {
|
||||
return models.JobPoolStats{
|
||||
Pools: []*models.JobPoolStatsData{
|
||||
&models.JobPoolStatsData{
|
||||
{
|
||||
Status: "running",
|
||||
},
|
||||
},
|
||||
|
@ -68,7 +68,7 @@ func BuildBlobURL(endpoint, repository, digest string) string {
|
||||
func GetTokenForRepo(repository, secret, internalTokenServiceURL string) (string, error) {
|
||||
credential := httpauth.NewSecretAuthorizer(secret)
|
||||
t, err := auth.GetToken(internalTokenServiceURL, true, credential,
|
||||
[]*token.ResourceActions{&token.ResourceActions{
|
||||
[]*token.ResourceActions{{
|
||||
Type: "repository",
|
||||
Name: repository,
|
||||
Actions: []string{"pull"},
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
"github.com/goharbor/harbor/src/jobservice/models"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -16,10 +16,10 @@ import (
|
||||
"github.com/goharbor/harbor/src/jobservice/errs"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/models"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/models"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -7,11 +7,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gocraft/work"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/robfig/cron"
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -13,11 +13,11 @@ import (
|
||||
|
||||
"github.com/robfig/cron"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/jobservice/env"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
"github.com/goharbor/harbor/src/jobservice/models"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/gocraft/work"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
//Sweeper take charge of clearing the outdated data such as scheduled jobs etc..
|
||||
|
@ -14,9 +14,9 @@ import (
|
||||
"github.com/goharbor/harbor/src/jobservice/opm"
|
||||
"github.com/goharbor/harbor/src/jobservice/period"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/jobservice/models"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -9,8 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gocraft/work"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/robfig/cron"
|
||||
"github.com/goharbor/harbor/src/jobservice/env"
|
||||
"github.com/goharbor/harbor/src/jobservice/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
@ -18,6 +16,8 @@ import (
|
||||
"github.com/goharbor/harbor/src/jobservice/opm"
|
||||
"github.com/goharbor/harbor/src/jobservice/period"
|
||||
"github.com/goharbor/harbor/src/jobservice/utils"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"github.com/goharbor/harbor/src/common/job"
|
||||
"github.com/goharbor/harbor/src/jobservice/api"
|
||||
"github.com/goharbor/harbor/src/jobservice/config"
|
||||
@ -23,6 +22,7 @@ import (
|
||||
"github.com/goharbor/harbor/src/jobservice/job/impl/scan"
|
||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||
"github.com/goharbor/harbor/src/jobservice/pool"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
commonsecret "github.com/goharbor/harbor/src/common/secret"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAuthorizeRequestInvalid(t *testing.T) {
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var c Client
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
gorilla_handlers "github.com/gorilla/handlers"
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
"github.com/goharbor/harbor/src/registryctl/auth"
|
||||
gorilla_handlers "github.com/gorilla/handlers"
|
||||
)
|
||||
|
||||
// NewHandlerChain returns a gorilla router which is wrapped by authenticate handler
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/registryctl/auth"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type fakeAuthenticator struct {
|
||||
|
@ -17,8 +17,8 @@ package handlers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/goharbor/harbor/src/registryctl/api"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func newRouter() http.Handler {
|
||||
|
@ -18,13 +18,13 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/goharbor/harbor/src/replication/source"
|
||||
"github.com/goharbor/harbor/src/replication/target"
|
||||
"github.com/goharbor/harbor/src/replication/trigger"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@ -81,7 +81,7 @@ func TestGetCandidates(t *testing.T) {
|
||||
policy := &models.ReplicationPolicy{
|
||||
ID: 1,
|
||||
Filters: []models.Filter{
|
||||
models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "*",
|
||||
},
|
||||
@ -94,11 +94,11 @@ func TestGetCandidates(t *testing.T) {
|
||||
sourcer := source.NewSourcer()
|
||||
|
||||
candidates := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:release-1.0",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
@ -110,7 +110,7 @@ func TestGetCandidates(t *testing.T) {
|
||||
assert.Equal(t, 2, len(result))
|
||||
|
||||
policy.Filters = []models.Filter{
|
||||
models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "release-*",
|
||||
},
|
||||
@ -121,7 +121,7 @@ func TestGetCandidates(t *testing.T) {
|
||||
// test label filter
|
||||
test.InitDatabaseFromEnv()
|
||||
policy.Filters = []models.Filter{
|
||||
models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: int64(1),
|
||||
},
|
||||
@ -134,17 +134,17 @@ func TestBuildFilterChain(t *testing.T) {
|
||||
policy := &models.ReplicationPolicy{
|
||||
ID: 1,
|
||||
Filters: []models.Filter{
|
||||
models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "*",
|
||||
},
|
||||
|
||||
models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "*",
|
||||
},
|
||||
|
||||
models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: int64(1),
|
||||
},
|
||||
|
@ -17,10 +17,10 @@ package event
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication/event/notification"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestHandleOfOnDeletionHandler(t *testing.T) {
|
||||
|
@ -17,10 +17,10 @@ package event
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication/event/notification"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestHandleOfOnPushHandler(t *testing.T) {
|
||||
|
@ -17,10 +17,10 @@ package event
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication/core"
|
||||
"github.com/goharbor/harbor/src/replication/event/notification"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestHandle(t *testing.T) {
|
||||
|
@ -18,43 +18,43 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/astaxie/beego/validation"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestValid(t *testing.T) {
|
||||
cases := map[*Filter]bool{
|
||||
&Filter{}: true,
|
||||
&Filter{
|
||||
{}: true,
|
||||
{
|
||||
Kind: "invalid_kind",
|
||||
}: true,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
}: true,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
}: false,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "*",
|
||||
}: false,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
}: true,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: "",
|
||||
}: true,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: 1.2,
|
||||
}: true,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: -1,
|
||||
}: true,
|
||||
&Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: 1,
|
||||
}: true,
|
||||
|
@ -18,20 +18,20 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/astaxie/beego/validation"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestValidOfTrigger(t *testing.T) {
|
||||
cases := map[*Trigger]bool{
|
||||
&Trigger{}: true,
|
||||
&Trigger{
|
||||
{}: true,
|
||||
{
|
||||
Kind: "invalid_kind",
|
||||
}: true,
|
||||
&Trigger{
|
||||
{
|
||||
Kind: replication.TriggerKindImmediate,
|
||||
}: false,
|
||||
&Trigger{
|
||||
{
|
||||
Kind: replication.TriggerKindSchedule,
|
||||
}: true,
|
||||
}
|
||||
@ -45,24 +45,24 @@ func TestValidOfTrigger(t *testing.T) {
|
||||
|
||||
func TestValidOfScheduleParam(t *testing.T) {
|
||||
cases := map[*ScheduleParam]bool{
|
||||
&ScheduleParam{}: true,
|
||||
&ScheduleParam{
|
||||
{}: true,
|
||||
{
|
||||
Type: "invalid_type",
|
||||
}: true,
|
||||
&ScheduleParam{
|
||||
{
|
||||
Type: replication.TriggerScheduleDaily,
|
||||
Offtime: 3600*24 + 1,
|
||||
}: true,
|
||||
&ScheduleParam{
|
||||
{
|
||||
Type: replication.TriggerScheduleDaily,
|
||||
Offtime: 3600 * 2,
|
||||
}: false,
|
||||
&ScheduleParam{
|
||||
{
|
||||
Type: replication.TriggerScheduleWeekly,
|
||||
Weekday: 0,
|
||||
Offtime: 3600 * 2,
|
||||
}: true,
|
||||
&ScheduleParam{
|
||||
{
|
||||
Type: replication.TriggerScheduleWeekly,
|
||||
Weekday: 7,
|
||||
Offtime: 3600 * 2,
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
)
|
||||
|
||||
func TestConvertToPersistModel(t *testing.T) {
|
||||
@ -31,7 +31,7 @@ func TestConvertToPersistModel(t *testing.T) {
|
||||
Kind: "trigger_kind",
|
||||
}
|
||||
filters := []models.Filter{
|
||||
models.Filter{
|
||||
{
|
||||
Kind: "filter_kind",
|
||||
Pattern: "filter_pattern",
|
||||
},
|
||||
|
@ -17,10 +17,10 @@ package source
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestBuild(t *testing.T) {
|
||||
@ -41,11 +41,11 @@ func TestDoFilter(t *testing.T) {
|
||||
filters := []Filter{projectFilter, repositoryFilter}
|
||||
|
||||
items := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
Value: "library",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
Value: "test",
|
||||
},
|
||||
@ -53,7 +53,7 @@ func TestDoFilter(t *testing.T) {
|
||||
chain := NewDefaultFilterChain(filters)
|
||||
items = chain.DoFilter(items)
|
||||
assert.EqualValues(t, []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "library/ubuntu",
|
||||
},
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInitOfLabelFilter(t *testing.T) {
|
||||
@ -38,7 +38,7 @@ func TestDoFilterOfLabelFilter(t *testing.T) {
|
||||
test.InitDatabaseFromEnv()
|
||||
filter := NewLabelFilter(1)
|
||||
items := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
|
@ -15,9 +15,9 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"testing"
|
||||
)
|
||||
@ -34,21 +34,21 @@ func TestPatternFilterGetConvertor(t *testing.T) {
|
||||
|
||||
func TestPatternFilterDoFilter(t *testing.T) {
|
||||
items := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:release-14.04",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:release-16.04",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:test",
|
||||
},
|
||||
|
@ -17,31 +17,31 @@ package source
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRepositoryConvert(t *testing.T) {
|
||||
items := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
Value: "library",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
},
|
||||
}
|
||||
expected := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "library/ubuntu",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "library/centos",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
},
|
||||
}
|
||||
@ -66,10 +66,10 @@ func (f *fakeRegistryAdaptor) GetNamespace(name string) models.Namespace {
|
||||
|
||||
func (f *fakeRegistryAdaptor) GetRepositories(namespace string) []models.Repository {
|
||||
return []models.Repository{
|
||||
models.Repository{
|
||||
{
|
||||
Name: "library/ubuntu",
|
||||
},
|
||||
models.Repository{
|
||||
{
|
||||
Name: "library/centos",
|
||||
},
|
||||
}
|
||||
@ -81,10 +81,10 @@ func (f *fakeRegistryAdaptor) GetRepository(name string, namespace string) model
|
||||
|
||||
func (f *fakeRegistryAdaptor) GetTags(repositoryName string, namespace string) []models.Tag {
|
||||
return []models.Tag{
|
||||
models.Tag{
|
||||
{
|
||||
Name: "14.04",
|
||||
},
|
||||
models.Tag{
|
||||
{
|
||||
Name: "16.04",
|
||||
},
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ package source
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/goharbor/harbor/src/replication/registry"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInitOfRepositoryFilter(t *testing.T) {
|
||||
@ -37,7 +37,7 @@ func TestDoFilterOfRepositoryFilter(t *testing.T) {
|
||||
// invalid filter item type
|
||||
filter := NewRepositoryFilter("", ®istry.HarborAdaptor{})
|
||||
items := filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: "invalid_type",
|
||||
},
|
||||
})
|
||||
@ -46,7 +46,7 @@ func TestDoFilterOfRepositoryFilter(t *testing.T) {
|
||||
// empty pattern
|
||||
filter = NewRepositoryFilter("", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "library/hello-world",
|
||||
},
|
||||
@ -56,7 +56,7 @@ func TestDoFilterOfRepositoryFilter(t *testing.T) {
|
||||
// non-empty pattern
|
||||
filter = NewRepositoryFilter("*", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world",
|
||||
},
|
||||
@ -66,7 +66,7 @@ func TestDoFilterOfRepositoryFilter(t *testing.T) {
|
||||
// non-empty pattern
|
||||
filter = NewRepositoryFilter("*", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
|
@ -15,9 +15,9 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"testing"
|
||||
)
|
||||
@ -34,25 +34,25 @@ func TestTagCombinationFilterGetConvertor(t *testing.T) {
|
||||
|
||||
func TestTagCombinationFilterDoFilter(t *testing.T) {
|
||||
items := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:invalid_tag:latest",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:14.04",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:16.04",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/centos:7",
|
||||
},
|
||||
|
@ -17,31 +17,31 @@ package source
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestTagConvert(t *testing.T) {
|
||||
items := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Value: "library/ubuntu",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
},
|
||||
}
|
||||
expected := []models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:14.04",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/ubuntu:16.04",
|
||||
},
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindProject,
|
||||
},
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ package source
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/goharbor/harbor/src/replication/registry"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInitOfTagFilter(t *testing.T) {
|
||||
@ -37,7 +37,7 @@ func TestDoFilterOfTagFilter(t *testing.T) {
|
||||
// invalid filter item type
|
||||
filter := NewTagFilter("", ®istry.HarborAdaptor{})
|
||||
items := filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: "invalid_type",
|
||||
},
|
||||
})
|
||||
@ -46,7 +46,7 @@ func TestDoFilterOfTagFilter(t *testing.T) {
|
||||
// empty pattern
|
||||
filter = NewTagFilter("", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
@ -56,7 +56,7 @@ func TestDoFilterOfTagFilter(t *testing.T) {
|
||||
// non-empty pattern
|
||||
filter = NewTagFilter("l*t", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
@ -66,7 +66,7 @@ func TestDoFilterOfTagFilter(t *testing.T) {
|
||||
// non-empty pattern
|
||||
filter = NewTagFilter("lates?", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
@ -76,7 +76,7 @@ func TestDoFilterOfTagFilter(t *testing.T) {
|
||||
// non-empty pattern
|
||||
filter = NewTagFilter("latest?", ®istry.HarborAdaptor{})
|
||||
items = filter.DoFilter([]models.FilterItem{
|
||||
models.FilterItem{
|
||||
{
|
||||
Kind: replication.FilterItemKindTag,
|
||||
Value: "library/hello-world:latest",
|
||||
},
|
||||
|
@ -17,11 +17,11 @@ package trigger
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestKindOfImmediateTrigger(t *testing.T) {
|
||||
|
@ -17,12 +17,12 @@ package trigger
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCreateTrigger(t *testing.T) {
|
||||
|
@ -17,8 +17,8 @@ package trigger
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestKindOfScheduleTrigger(t *testing.T) {
|
||||
|
@ -17,10 +17,10 @@ package trigger
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMethodsOfWatchList(t *testing.T) {
|
||||
|
@ -28,12 +28,12 @@ import (
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/dghubble/sling"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/dao/project"
|
||||
common_http "github.com/goharbor/harbor/src/common/http"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -228,7 +228,7 @@ func (msc *mockSecurityContext) HasAllPerm(projectIDOrName interface{}) bool {
|
||||
|
||||
//Get current user's all project
|
||||
func (msc *mockSecurityContext) GetMyProjects() ([]*models.Project, error) {
|
||||
return []*models.Project{&models.Project{ProjectID: 0, Name: "repo1"}}, nil
|
||||
return []*models.Project{{ProjectID: 0, Name: "repo1"}}, nil
|
||||
}
|
||||
|
||||
//Get user's role in provided project
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/ui/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetConfig(t *testing.T) {
|
||||
|
@ -20,13 +20,13 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
rep_models "github.com/goharbor/harbor/src/replication/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -46,7 +46,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -55,7 +55,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -66,7 +66,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 non-sysadmin try to create global label
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -80,7 +80,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 non-member user try to create project label
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -95,7 +95,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 developer try to create project label
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -110,7 +110,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 404 non-exist project
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -125,7 +125,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -141,7 +141,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 409
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: labelAPIBasePath,
|
||||
@ -162,7 +162,7 @@ func TestLabelAPIPost(t *testing.T) {
|
||||
func TestLabelAPIGet(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, 0),
|
||||
@ -171,7 +171,7 @@ func TestLabelAPIGet(t *testing.T) {
|
||||
},
|
||||
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, 1000),
|
||||
@ -180,7 +180,7 @@ func TestLabelAPIGet(t *testing.T) {
|
||||
},
|
||||
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -194,7 +194,7 @@ func TestLabelAPIGet(t *testing.T) {
|
||||
func TestLabelAPIList(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 400 no scope query string
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: labelAPIBasePath,
|
||||
@ -203,7 +203,7 @@ func TestLabelAPIList(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400 invalid scope
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: labelAPIBasePath,
|
||||
@ -217,7 +217,7 @@ func TestLabelAPIList(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400 invalid project_id
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: labelAPIBasePath,
|
||||
@ -272,7 +272,7 @@ func TestLabelAPIList(t *testing.T) {
|
||||
func TestLabelAPIPut(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -281,7 +281,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, 0),
|
||||
@ -291,7 +291,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
},
|
||||
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, 10000),
|
||||
@ -301,7 +301,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 non-member user
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -311,7 +311,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 developer
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -321,7 +321,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -336,7 +336,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
},
|
||||
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -365,7 +365,7 @@ func TestLabelAPIPut(t *testing.T) {
|
||||
func TestLabelAPIDelete(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -374,7 +374,7 @@ func TestLabelAPIDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, 0),
|
||||
@ -384,7 +384,7 @@ func TestLabelAPIDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, 10000),
|
||||
@ -394,7 +394,7 @@ func TestLabelAPIDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 non-member user
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -404,7 +404,7 @@ func TestLabelAPIDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 403 developer
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -414,7 +414,7 @@ func TestLabelAPIDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -424,7 +424,7 @@ func TestLabelAPIDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", labelAPIBasePath, labelID),
|
||||
@ -477,7 +477,7 @@ func TestListResources(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d/resources", labelAPIBasePath, globalLabelID),
|
||||
@ -485,7 +485,7 @@ func TestListResources(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d/resources", labelAPIBasePath, 10000),
|
||||
@ -494,7 +494,7 @@ func TestListResources(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 403: global level label
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d/resources", labelAPIBasePath, globalLabelID),
|
||||
@ -503,7 +503,7 @@ func TestListResources(t *testing.T) {
|
||||
code: http.StatusForbidden,
|
||||
},
|
||||
// 403: project level label
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d/resources", labelAPIBasePath, projectLabelID),
|
||||
|
@ -9,14 +9,14 @@ import (
|
||||
|
||||
func TestLDAPPing(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/ldap/ping",
|
||||
},
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/ldap/ping",
|
||||
@ -24,7 +24,7 @@ func TestLDAPPing(t *testing.T) {
|
||||
},
|
||||
code: http.StatusOK,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/ldap/ping",
|
||||
@ -47,14 +47,14 @@ func TestLDAPPing(t *testing.T) {
|
||||
|
||||
func TestLDAPUserSearch(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/ldap/users/search?username=mike",
|
||||
},
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/ldap/users/search?username=mike",
|
||||
@ -68,14 +68,14 @@ func TestLDAPUserSearch(t *testing.T) {
|
||||
|
||||
func TestLDAPGroupSearch(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/ldap/groups/search?groupname=harbor_users",
|
||||
},
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/ldap/groups/search?groupname=harbor_users",
|
||||
@ -89,14 +89,14 @@ func TestLDAPGroupSearch(t *testing.T) {
|
||||
|
||||
func TestLDAPGroupSearchWithDN(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/ldap/groups/search?groupdn=cn=harbor_users,ou=groups,dc=example,dc=com",
|
||||
},
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/ldap/groups/search?groupname=cn=harbor_users,ou=groups,dc=example,dc=com",
|
||||
@ -110,7 +110,7 @@ func TestLDAPGroupSearchWithDN(t *testing.T) {
|
||||
|
||||
func TestLDAPImportUser(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/ldap/users/import",
|
||||
@ -120,7 +120,7 @@ func TestLDAPImportUser(t *testing.T) {
|
||||
},
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/ldap/users/import",
|
||||
|
@ -19,10 +19,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLogGet(t *testing.T) {
|
||||
|
@ -18,9 +18,9 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
)
|
||||
|
||||
func TestValidateProjectMetadata(t *testing.T) {
|
||||
|
@ -24,11 +24,11 @@ import (
|
||||
|
||||
"github.com/goharbor/harbor/src/chartserver"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/tests/apitests/apilib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var addProject *apilib.ProjectReq
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
func TestProjectMemberAPI_Get(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/1/members",
|
||||
@ -35,7 +35,7 @@ func TestProjectMemberAPI_Get(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
//200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/1/members",
|
||||
@ -44,7 +44,7 @@ func TestProjectMemberAPI_Get(t *testing.T) {
|
||||
code: http.StatusOK,
|
||||
},
|
||||
//400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/0/members",
|
||||
@ -53,7 +53,7 @@ func TestProjectMemberAPI_Get(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/1/members/121",
|
||||
@ -62,7 +62,7 @@ func TestProjectMemberAPI_Get(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/99999/members/121",
|
||||
@ -87,7 +87,7 @@ func TestProjectMemberAPI_Post(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/projects/1/members",
|
||||
@ -100,7 +100,7 @@ func TestProjectMemberAPI_Post(t *testing.T) {
|
||||
},
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/projects/1/members",
|
||||
@ -114,7 +114,7 @@ func TestProjectMemberAPI_Post(t *testing.T) {
|
||||
},
|
||||
code: http.StatusCreated,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/projects/1/members",
|
||||
@ -128,7 +128,7 @@ func TestProjectMemberAPI_Post(t *testing.T) {
|
||||
},
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/projects/1/members",
|
||||
@ -142,7 +142,7 @@ func TestProjectMemberAPI_Post(t *testing.T) {
|
||||
},
|
||||
code: http.StatusInternalServerError,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/1/members?entityname=restuser",
|
||||
@ -150,7 +150,7 @@ func TestProjectMemberAPI_Post(t *testing.T) {
|
||||
},
|
||||
code: http.StatusOK,
|
||||
},
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: "/api/projects/1/members",
|
||||
@ -187,7 +187,7 @@ func TestProjectMemberAPI_PutAndDelete(t *testing.T) {
|
||||
badURL := fmt.Sprintf("/api/projects/1/members/%v", 0)
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: URL,
|
||||
@ -198,7 +198,7 @@ func TestProjectMemberAPI_PutAndDelete(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: URL,
|
||||
@ -210,7 +210,7 @@ func TestProjectMemberAPI_PutAndDelete(t *testing.T) {
|
||||
code: http.StatusOK,
|
||||
},
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: badURL,
|
||||
@ -222,7 +222,7 @@ func TestProjectMemberAPI_PutAndDelete(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: URL,
|
||||
@ -234,7 +234,7 @@ func TestProjectMemberAPI_PutAndDelete(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: URL,
|
||||
|
@ -3,8 +3,8 @@ package api
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/tests/apitests/apilib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var adminJob001 apilib.GCReq
|
||||
|
@ -21,14 +21,14 @@ import (
|
||||
|
||||
"github.com/goharbor/harbor/src/common/dao/project"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
rep_models "github.com/goharbor/harbor/src/replication/models"
|
||||
api_models "github.com/goharbor/harbor/src/ui/api/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -63,7 +63,7 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
@ -71,7 +71,7 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 403
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
@ -81,7 +81,7 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
},
|
||||
|
||||
// 400, invalid name
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
@ -91,7 +91,7 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400, invalid projects
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
@ -103,14 +103,14 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400, invalid targets
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
@ -120,24 +120,24 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400, invalid filters
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: "invalid_filter_kind",
|
||||
Pattern: "",
|
||||
},
|
||||
@ -148,24 +148,24 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400, invalid trigger
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
@ -179,24 +179,24 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 404, project not found
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: 10000,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
@ -210,24 +210,24 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 404, target not found
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: 10000,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
@ -241,28 +241,28 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 404, label not found
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: 10000,
|
||||
},
|
||||
@ -276,28 +276,28 @@ func TestRepPolicyAPIPost(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 201
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: repPolicyAPIBasePath,
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindLabel,
|
||||
Value: labelID2,
|
||||
},
|
||||
@ -320,7 +320,7 @@ func TestRepPolicyAPIGet(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, 10000),
|
||||
@ -329,7 +329,7 @@ func TestRepPolicyAPIGet(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, policyID),
|
||||
@ -512,7 +512,7 @@ func TestRepPolicyAPIList(t *testing.T) {
|
||||
func TestRepPolicyAPIPut(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, 10000),
|
||||
@ -521,24 +521,24 @@ func TestRepPolicyAPIPut(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 400, invalid trigger
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, policyID),
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
@ -552,24 +552,24 @@ func TestRepPolicyAPIPut(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, policyID),
|
||||
bodyJSON: &api_models.ReplicationPolicy{
|
||||
Name: policyName,
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: projectID,
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: targetID,
|
||||
},
|
||||
},
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: replication.FilterItemKindRepository,
|
||||
Pattern: "*",
|
||||
},
|
||||
@ -590,7 +590,7 @@ func TestRepPolicyAPIPut(t *testing.T) {
|
||||
func TestRepPolicyAPIDelete(t *testing.T) {
|
||||
cases := []*codeCheckingCase{
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, 10000),
|
||||
@ -599,7 +599,7 @@ func TestRepPolicyAPIDelete(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("%s/%d", repPolicyAPIBasePath, policyID),
|
||||
@ -627,7 +627,7 @@ func TestConvertToRepPolicy(t *testing.T) {
|
||||
Name: "policy",
|
||||
Description: "description",
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: "filter_kind_01",
|
||||
Pattern: "*",
|
||||
},
|
||||
@ -637,13 +637,13 @@ func TestConvertToRepPolicy(t *testing.T) {
|
||||
Kind: "trigger_kind_01",
|
||||
},
|
||||
Projects: []*models.Project{
|
||||
&models.Project{
|
||||
{
|
||||
ProjectID: 1,
|
||||
Name: "library",
|
||||
},
|
||||
},
|
||||
Targets: []*models.RepTarget{
|
||||
&models.RepTarget{
|
||||
{
|
||||
ID: 1,
|
||||
},
|
||||
},
|
||||
@ -653,7 +653,7 @@ func TestConvertToRepPolicy(t *testing.T) {
|
||||
Name: "policy",
|
||||
Description: "description",
|
||||
Filters: []rep_models.Filter{
|
||||
rep_models.Filter{
|
||||
{
|
||||
Kind: "filter_kind_01",
|
||||
Pattern: "*",
|
||||
},
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/replication"
|
||||
api_models "github.com/goharbor/harbor/src/ui/api/models"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -52,7 +52,7 @@ func TestReplicationAPIPost(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: replicationAPIBaseURL,
|
||||
@ -63,7 +63,7 @@ func TestReplicationAPIPost(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: replicationAPIBaseURL,
|
||||
@ -75,7 +75,7 @@ func TestReplicationAPIPost(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: replicationAPIBaseURL,
|
||||
|
@ -19,11 +19,11 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -60,7 +60,7 @@ func TestAddToImage(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath,
|
||||
repository, tag),
|
||||
@ -69,7 +69,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 403
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath,
|
||||
repository, tag),
|
||||
@ -79,7 +79,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusForbidden,
|
||||
},
|
||||
// 404 repository doesn't exist
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/library/non-exist-repo/tags/%s/labels", resourceLabelAPIBasePath, tag),
|
||||
method: http.MethodPost,
|
||||
@ -88,7 +88,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 404 image doesn't exist
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/non-exist-tag/labels", resourceLabelAPIBasePath, repository),
|
||||
method: http.MethodPost,
|
||||
@ -97,7 +97,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 400
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath, repository, tag),
|
||||
method: http.MethodPost,
|
||||
@ -106,7 +106,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 404 label doesn't exist
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath,
|
||||
repository, tag),
|
||||
@ -121,7 +121,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 400 system level label
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath,
|
||||
repository, tag),
|
||||
@ -136,7 +136,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400 try to add the label of project1 to the image under project2
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath,
|
||||
repository, tag),
|
||||
@ -151,7 +151,7 @@ func TestAddToImage(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
url: fmt.Sprintf("%s/%s/tags/%s/labels", resourceLabelAPIBasePath,
|
||||
repository, tag),
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/dao/project"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetRepos(t *testing.T) {
|
||||
@ -256,7 +256,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "non_exist_repository",
|
||||
@ -265,7 +265,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "library/hello-world",
|
||||
@ -274,7 +274,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 403 non-member
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "library/hello-world",
|
||||
@ -284,7 +284,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
code: http.StatusForbidden,
|
||||
},
|
||||
// 403 project guest
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "library/hello-world",
|
||||
@ -294,7 +294,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
code: http.StatusForbidden,
|
||||
},
|
||||
// 200 project developer
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "library/hello-world",
|
||||
@ -304,7 +304,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
code: http.StatusOK,
|
||||
},
|
||||
// 200 project admin
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "library/hello-world",
|
||||
@ -314,7 +314,7 @@ func TestPutOfRepository(t *testing.T) {
|
||||
code: http.StatusOK,
|
||||
},
|
||||
// 200 system admin
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: base + "library/hello-world",
|
||||
|
@ -21,10 +21,10 @@ import (
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
member "github.com/goharbor/harbor/src/common/dao/project"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSearch(t *testing.T) {
|
||||
|
@ -20,9 +20,9 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/goharbor/harbor/tests/apitests/apilib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/tests/apitests/apilib"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -18,13 +18,13 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/api"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/tests/apitests/apilib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
@ -360,7 +360,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
// unauthorized
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
@ -368,7 +368,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
// 404
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(10000),
|
||||
@ -380,7 +380,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusNotFound,
|
||||
},
|
||||
// 403, a normal user tries to change password of others
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user02.UserID),
|
||||
@ -392,7 +392,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusForbidden,
|
||||
},
|
||||
// 400, empty old password
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
@ -405,7 +405,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 400, empty new password
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
@ -420,7 +420,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 403, incorrect old password
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
@ -436,7 +436,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusForbidden,
|
||||
},
|
||||
// 200, normal user change own password
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
@ -453,7 +453,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
},
|
||||
// 400, admin user change password of others.
|
||||
// the new password is same with the old one
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
@ -465,7 +465,7 @@ func TestUsersUpdatePassword(t *testing.T) {
|
||||
code: http.StatusBadRequest,
|
||||
},
|
||||
// 200, admin user change password of others
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: buildChangeUserPasswordURL(user01.UserID),
|
||||
|
@ -44,7 +44,7 @@ func TestUserGroupAPI_GetAndDelete(t *testing.T) {
|
||||
defer group.DeleteUserGroup(groupID)
|
||||
cases := []*codeCheckingCase{
|
||||
// 401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: URL,
|
||||
@ -53,7 +53,7 @@ func TestUserGroupAPI_GetAndDelete(t *testing.T) {
|
||||
},
|
||||
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("/api/usergroups/%d", groupID),
|
||||
@ -62,7 +62,7 @@ func TestUserGroupAPI_GetAndDelete(t *testing.T) {
|
||||
code: http.StatusOK,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodGet,
|
||||
url: fmt.Sprintf("/api/usergroups"),
|
||||
@ -71,7 +71,7 @@ func TestUserGroupAPI_GetAndDelete(t *testing.T) {
|
||||
code: http.StatusOK,
|
||||
},
|
||||
// 200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodDelete,
|
||||
url: fmt.Sprintf("/api/usergroups/%d", groupID),
|
||||
@ -97,7 +97,7 @@ func TestUserGroupAPI_Post(t *testing.T) {
|
||||
|
||||
cases := []*codeCheckingCase{
|
||||
//409
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPost,
|
||||
url: "/api/usergroups",
|
||||
@ -127,7 +127,7 @@ func TestUserGroupAPI_Put(t *testing.T) {
|
||||
}
|
||||
cases := []*codeCheckingCase{
|
||||
//401
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("/api/usergroups/%d", groupID),
|
||||
@ -138,7 +138,7 @@ func TestUserGroupAPI_Put(t *testing.T) {
|
||||
code: http.StatusUnauthorized,
|
||||
},
|
||||
//200
|
||||
&codeCheckingCase{
|
||||
{
|
||||
request: &testingRequest{
|
||||
method: http.MethodPut,
|
||||
url: fmt.Sprintf("/api/usergroups/%d", groupID),
|
||||
|
@ -17,9 +17,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var l = NewUserLock(2 * time.Second)
|
||||
|
@ -18,13 +18,13 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
utilstest "github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/common/utils/uaa"
|
||||
"github.com/goharbor/harbor/src/ui/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
@ -19,9 +19,9 @@ import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// test functions under package ui/config
|
||||
|
@ -26,13 +26,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/ui/config"
|
||||
"github.com/goharbor/harbor/src/ui/proxy"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
//const (
|
||||
|
@ -20,10 +20,10 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
utilstest "github.com/goharbor/harbor/src/common/utils/test"
|
||||
"github.com/goharbor/harbor/src/ui/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestReadonlyFilter(t *testing.T) {
|
||||
|
@ -58,22 +58,22 @@ var (
|
||||
// in the slice
|
||||
basicAuthReqPatterns = []*pathMethod{
|
||||
// create project
|
||||
&pathMethod{
|
||||
{
|
||||
path: "/api/projects",
|
||||
method: http.MethodPost,
|
||||
},
|
||||
// token service
|
||||
&pathMethod{
|
||||
{
|
||||
path: "/service/token",
|
||||
method: http.MethodGet,
|
||||
},
|
||||
// delete repository
|
||||
&pathMethod{
|
||||
{
|
||||
path: "/api/repositories/" + reference.NameRegexp.String(),
|
||||
method: http.MethodDelete,
|
||||
},
|
||||
// delete tag
|
||||
&pathMethod{
|
||||
{
|
||||
path: "/api/repositories/" + reference.NameRegexp.String() + "/tags/" + reference.TagRegexp.String(),
|
||||
method: http.MethodDelete,
|
||||
},
|
||||
|
@ -28,7 +28,6 @@ import (
|
||||
"github.com/astaxie/beego"
|
||||
beegoctx "github.com/astaxie/beego/context"
|
||||
"github.com/astaxie/beego/session"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/goharbor/harbor/src/common/dao"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
commonsecret "github.com/goharbor/harbor/src/common/secret"
|
||||
@ -40,6 +39,7 @@ import (
|
||||
"github.com/goharbor/harbor/src/ui/config"
|
||||
"github.com/goharbor/harbor/src/ui/promgr"
|
||||
driver_local "github.com/goharbor/harbor/src/ui/promgr/pmsdriver/local"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user