mirror of
https://github.com/netbirdio/management-refactor.git
synced 2026-05-22 17:12:59 -07:00
fix cloud injection
This commit is contained in:
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/activity"
|
||||
nbpeer "github.com/netbirdio/netbird/management/server/peer"
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/management-refactor/management/server/activity"
|
||||
nbpeer "github.com/netbirdio/management-refactor/management/server/peer"
|
||||
"github.com/netbirdio/management-refactor/management/server/store"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/modules/peers"
|
||||
)
|
||||
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
nbAccount "github.com/netbirdio/netbird/management/server/account"
|
||||
nbpeer "github.com/netbirdio/netbird/management/server/peer"
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
nbAccount "github.com/netbirdio/management-refactor/management/server/account"
|
||||
nbpeer "github.com/netbirdio/management-refactor/management/server/peer"
|
||||
"github.com/netbirdio/management-refactor/management/server/store"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
)
|
||||
|
||||
type MockStore struct {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/http/util"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/util"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/shared/db"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/errors"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/http/util"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/util"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/shared/db"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/errors"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/netbirdio/netbird/management/server/integrations/extra_settings"
|
||||
types2 "github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/management/server/integrations/extra_settings"
|
||||
types2 "github.com/netbirdio/management-refactor/management/server/types"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/modules/users"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/activity"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/http/util"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/util"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/shared/db"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/errors"
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/netbirdio/netbird/management/server/http/api"
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/api"
|
||||
"github.com/netbirdio/management-refactor/management/server/store"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/shared/db"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/permissions"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/http/util"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/util"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/shared/db"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/errors"
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/netbirdio/netbird/management/server/activity"
|
||||
"github.com/netbirdio/management-refactor/management/server/activity"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/activity"
|
||||
"github.com/netbirdio/management-refactor/management/server/activity"
|
||||
)
|
||||
|
||||
func TestNewSQLiteStore(t *testing.T) {
|
||||
|
||||
@@ -20,18 +20,18 @@ import (
|
||||
|
||||
integrationsConfig "github.com/netbirdio/management-integrations/integrations/config"
|
||||
|
||||
"github.com/netbirdio/netbird/encryption"
|
||||
"github.com/netbirdio/netbird/management/proto"
|
||||
"github.com/netbirdio/netbird/management/server/account"
|
||||
"github.com/netbirdio/netbird/management/server/activity"
|
||||
"github.com/netbirdio/netbird/management/server/auth"
|
||||
nbContext "github.com/netbirdio/netbird/management/server/context"
|
||||
nbpeer "github.com/netbirdio/netbird/management/server/peer"
|
||||
"github.com/netbirdio/netbird/management/server/posture"
|
||||
"github.com/netbirdio/netbird/management/server/settings"
|
||||
internalStatus "github.com/netbirdio/netbird/management/server/status"
|
||||
"github.com/netbirdio/netbird/management/server/telemetry"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/encryption"
|
||||
"github.com/netbirdio/management-refactor/management/proto"
|
||||
"github.com/netbirdio/management-refactor/management/server/account"
|
||||
"github.com/netbirdio/management-refactor/management/server/activity"
|
||||
"github.com/netbirdio/management-refactor/management/server/auth"
|
||||
nbContext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
nbpeer "github.com/netbirdio/management-refactor/management/server/peer"
|
||||
"github.com/netbirdio/management-refactor/management/server/posture"
|
||||
"github.com/netbirdio/management-refactor/management/server/settings"
|
||||
internalStatus "github.com/netbirdio/management-refactor/management/server/status"
|
||||
"github.com/netbirdio/management-refactor/management/server/telemetry"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
)
|
||||
|
||||
// GRPCServer an instance of a Management gRPC API server
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/netbirdio/netbird/management/proto"
|
||||
"github.com/netbirdio/netbird/management/server/telemetry"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/management/proto"
|
||||
"github.com/netbirdio/management-refactor/management/server/telemetry"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
)
|
||||
|
||||
const channelBufferSize = 100
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/netbirdio/netbird/management/proto"
|
||||
"github.com/netbirdio/management-refactor/management/proto"
|
||||
)
|
||||
|
||||
// var peersUpdater *UpdateChannel
|
||||
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
"github.com/golang-jwt/jwt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/auth"
|
||||
nbjwt "github.com/netbirdio/netbird/management/server/auth/jwt"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/util"
|
||||
"github.com/netbirdio/management-refactor/management/server/auth"
|
||||
nbjwt "github.com/netbirdio/management-refactor/management/server/auth/jwt"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/util"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/http/middleware/bypass"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/middleware/bypass"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/http/middleware/bypass"
|
||||
"github.com/netbirdio/management-refactor/management/server/http/middleware/bypass"
|
||||
)
|
||||
|
||||
func TestGetList(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/golang-jwt/jwt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"hash/crc32"
|
||||
|
||||
"github.com/golang-jwt/jwt"
|
||||
"github.com/netbirdio/netbird/base62"
|
||||
nbjwt "github.com/netbirdio/netbird/management/server/auth/jwt"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/base62"
|
||||
nbjwt "github.com/netbirdio/management-refactor/management/server/auth/jwt"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/store"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/modules/accounts/settings"
|
||||
"github.com/netbirdio/management-refactor/internals/modules/users"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/golang-jwt/jwt"
|
||||
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -16,11 +16,11 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/auth"
|
||||
nbjwt "github.com/netbirdio/netbird/management/server/auth/jwt"
|
||||
nbcontext "github.com/netbirdio/netbird/management/server/context"
|
||||
"github.com/netbirdio/netbird/management/server/store"
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/management-refactor/management/server/auth"
|
||||
nbjwt "github.com/netbirdio/management-refactor/management/server/auth/jwt"
|
||||
nbcontext "github.com/netbirdio/management-refactor/management/server/context"
|
||||
"github.com/netbirdio/management-refactor/management/server/store"
|
||||
"github.com/netbirdio/management-refactor/management/server/types"
|
||||
)
|
||||
|
||||
func TestAuthManager_GetAccountInfoFromPAT(t *testing.T) {
|
||||
@@ -231,7 +231,7 @@ func TestAuthManager_ValidateAndParseToken(t *testing.T) {
|
||||
return fmt.Sprintf("%s/%s", audience, name)
|
||||
}
|
||||
|
||||
lastLogin := time.Date(2025, 2, 12, 14, 25, 26, 0, time.UTC) //"2025-02-12T14:25:26.186Z"
|
||||
lastLogin := time.Date(2025, 2, 12, 14, 25, 26, 0, time.UTC) // "2025-02-12T14:25:26.186Z"
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
@@ -5,14 +5,18 @@
|
||||
package permissions
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
"context"
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
modules "github.com/netbirdio/netbird/management/server/permissions/modules"
|
||||
operations "github.com/netbirdio/netbird/management/server/permissions/operations"
|
||||
roles "github.com/netbirdio/netbird/management/server/permissions/roles"
|
||||
types "github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/golang/mock/gomock"
|
||||
context0 "github.com/netbirdio/netbird/management/server/context"
|
||||
|
||||
"github.com/netbirdio/management-refactor/internals/modules/users"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/db"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/permissions/modules"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/permissions/operations"
|
||||
"github.com/netbirdio/management-refactor/internals/shared/permissions/roles"
|
||||
)
|
||||
|
||||
// MockManager is a mock of Manager interface.
|
||||
@@ -38,8 +42,20 @@ func (m *MockManager) EXPECT() *MockManagerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Init mocks base method.
|
||||
func (m *MockManager) Init(userManager userManager) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Init", userManager)
|
||||
}
|
||||
|
||||
// Init indicates an expected call of Init.
|
||||
func (mr *MockManagerMockRecorder) Init(userManager interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockManager)(nil).Init), userManager)
|
||||
}
|
||||
|
||||
// ValidateAccountAccess mocks base method.
|
||||
func (m *MockManager) ValidateAccountAccess(ctx context.Context, accountID string, user *types.User, allowOwnerAndAdmin bool) error {
|
||||
func (m *MockManager) ValidateAccountAccess(ctx context.Context, accountID string, user *users.User, allowOwnerAndAdmin bool) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ValidateAccountAccess", ctx, accountID, user, allowOwnerAndAdmin)
|
||||
ret0, _ := ret[0].(error)
|
||||
@@ -80,3 +96,93 @@ func (mr *MockManagerMockRecorder) ValidateUserPermissions(ctx, accountID, userI
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateUserPermissions", reflect.TypeOf((*MockManager)(nil).ValidateUserPermissions), ctx, accountID, userID, module, operation)
|
||||
}
|
||||
|
||||
// WithPermission mocks base method.
|
||||
func (m *MockManager) WithPermission(module modules.Module, operation operations.Operation, handlerFunc func(http.ResponseWriter, *http.Request, *context0.UserAuth)) http.HandlerFunc {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "WithPermission", module, operation, handlerFunc)
|
||||
ret0, _ := ret[0].(http.HandlerFunc)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// WithPermission indicates an expected call of WithPermission.
|
||||
func (mr *MockManagerMockRecorder) WithPermission(module, operation, handlerFunc interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithPermission", reflect.TypeOf((*MockManager)(nil).WithPermission), module, operation, handlerFunc)
|
||||
}
|
||||
|
||||
// MockuserManager is a mock of userManager interface.
|
||||
type MockuserManager struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockuserManagerMockRecorder
|
||||
}
|
||||
|
||||
// MockuserManagerMockRecorder is the mock recorder for MockuserManager.
|
||||
type MockuserManagerMockRecorder struct {
|
||||
mock *MockuserManager
|
||||
}
|
||||
|
||||
// NewMockuserManager creates a new mock instance.
|
||||
func NewMockuserManager(ctrl *gomock.Controller) *MockuserManager {
|
||||
mock := &MockuserManager{ctrl: ctrl}
|
||||
mock.recorder = &MockuserManagerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockuserManager) EXPECT() *MockuserManagerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetUserByID mocks base method.
|
||||
func (m *MockuserManager) GetUserByID(ctx context.Context, tx db.Transaction, strength db.LockingStrength, id string) (*users.User, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetUserByID", ctx, tx, strength, id)
|
||||
ret0, _ := ret[0].(*users.User)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetUserByID indicates an expected call of GetUserByID.
|
||||
func (mr *MockuserManagerMockRecorder) GetUserByID(ctx, tx, strength, id interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByID", reflect.TypeOf((*MockuserManager)(nil).GetUserByID), ctx, tx, strength, id)
|
||||
}
|
||||
|
||||
// MockPermissionValidator is a mock of PermissionValidator interface.
|
||||
type MockPermissionValidator struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockPermissionValidatorMockRecorder
|
||||
}
|
||||
|
||||
// MockPermissionValidatorMockRecorder is the mock recorder for MockPermissionValidator.
|
||||
type MockPermissionValidatorMockRecorder struct {
|
||||
mock *MockPermissionValidator
|
||||
}
|
||||
|
||||
// NewMockPermissionValidator creates a new mock instance.
|
||||
func NewMockPermissionValidator(ctrl *gomock.Controller) *MockPermissionValidator {
|
||||
mock := &MockPermissionValidator{ctrl: ctrl}
|
||||
mock.recorder = &MockPermissionValidatorMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockPermissionValidator) EXPECT() *MockPermissionValidatorMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ValidateUserPermissions mocks base method.
|
||||
func (m *MockPermissionValidator) ValidateUserPermissions(ctx context.Context, accountID, userID string, module modules.Module, operation operations.Operation) (bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ValidateUserPermissions", ctx, accountID, userID, module, operation)
|
||||
ret0, _ := ret[0].(bool)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ValidateUserPermissions indicates an expected call of ValidateUserPermissions.
|
||||
func (mr *MockPermissionValidatorMockRecorder) ValidateUserPermissions(ctx, accountID, userID, module, operation interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateUserPermissions", reflect.TypeOf((*MockPermissionValidator)(nil).ValidateUserPermissions), ctx, accountID, userID, module, operation)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user