mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:34:14 -04:00
This reverts commit 24df442198.
This commit is contained in:
@@ -64,7 +64,7 @@ var (
|
||||
config.HttpConfig.IdpSignKeyRefreshEnabled = idpSignKeyRefreshEnabled
|
||||
}
|
||||
|
||||
tlsEnabled := false
|
||||
var tlsEnabled bool
|
||||
if mgmtLetsencryptDomain != "" || (config.HttpConfig.CertFile != "" && config.HttpConfig.CertKey != "") {
|
||||
tlsEnabled = true
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ func (s *LoginFilterTestSuite) TestBanDurationIncreasesExponentially() {
|
||||
s.True(s.filter.logged[pubKey].isBanned)
|
||||
s.Equal(2, s.filter.logged[pubKey].banLevel)
|
||||
secondBanDuration := s.filter.logged[pubKey].banExpiresAt.Sub(s.filter.logged[pubKey].lastSeen)
|
||||
// nolint
|
||||
expectedSecondDuration := time.Duration(float64(baseBan) * math.Pow(2, 1))
|
||||
s.InDelta(expectedSecondDuration, secondBanDuration, float64(time.Millisecond))
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ func (am *DefaultAccountManager) isCacheFresh(ctx context.Context, accountUsers
|
||||
for user, loggedInOnce := range accountUsers {
|
||||
if datum, ok := userDataMap[user]; ok {
|
||||
// check if the matching user data has a pending invite and if the user has logged in once, forcing the cache to be refreshed
|
||||
if datum.AppMetadata.WTPendingInvite != nil && *datum.AppMetadata.WTPendingInvite && loggedInOnce == true { //nolint:gosimple
|
||||
if datum.AppMetadata.WTPendingInvite != nil && *datum.AppMetadata.WTPendingInvite && loggedInOnce == true { //nolint
|
||||
log.WithContext(ctx).Infof("user %s has a pending invite and has logged in once, cache invalid", user)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ func TestAccountManager_SetOrUpdateDomain(t *testing.T) {
|
||||
t.Fatalf("expected to create an account for a user %s", userId)
|
||||
}
|
||||
|
||||
if account != nil && account.Domain != domain {
|
||||
if account.Domain != domain {
|
||||
t.Errorf("setting account domain failed, expected %s, got %s", domain, account.Domain)
|
||||
}
|
||||
|
||||
@@ -768,7 +768,7 @@ func TestAccountManager_SetOrUpdateDomain(t *testing.T) {
|
||||
t.Fatalf("expected to get an account for a user %s", userId)
|
||||
}
|
||||
|
||||
if account != nil && account.Domain != domain {
|
||||
if account.Domain != domain {
|
||||
t.Errorf("updating domain. expected %s got %s", domain, account.Domain)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func initPostureChecksTestData(postureChecks ...*posture.Checks) *postureChecksH
|
||||
testPostureChecks[postureChecks.ID] = postureChecks
|
||||
|
||||
if err := postureChecks.Validate(); err != nil {
|
||||
return nil, status.Errorf(status.InvalidArgument, "%s", err.Error()) //nolint
|
||||
return nil, status.Errorf(status.InvalidArgument, "%v", err) //nolint
|
||||
}
|
||||
|
||||
return postureChecks, nil
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build benchmark
|
||||
// +build benchmark
|
||||
|
||||
package benchmarks
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build benchmark
|
||||
// +build benchmark
|
||||
|
||||
package benchmarks
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build benchmark
|
||||
// +build benchmark
|
||||
|
||||
package benchmarks
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package integration
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ func NewPocketIdManager(config PocketIdClientConfig, appMetrics telemetry.AppMet
|
||||
func (p *PocketIdManager) request(ctx context.Context, method, resource string, query *url.Values, body string) ([]byte, error) {
|
||||
var MethodsWithBody = []string{http.MethodPost, http.MethodPut}
|
||||
if !slices.Contains(MethodsWithBody, method) && body != "" {
|
||||
return nil, fmt.Errorf("Body provided to unsupported method: %s", method)
|
||||
return nil, fmt.Errorf("body provided to unsupported method: %s", method)
|
||||
}
|
||||
|
||||
reqURL := fmt.Sprintf("%s/api/%s", p.managementEndpoint, resource)
|
||||
@@ -301,7 +301,7 @@ func (p *PocketIdManager) CreateUser(ctx context.Context, email, name, accountID
|
||||
if p.appMetrics != nil {
|
||||
p.appMetrics.IDPMetrics().CountCreateUser()
|
||||
}
|
||||
var pending bool = true
|
||||
pending := true
|
||||
ret := &UserData{
|
||||
Email: email,
|
||||
Name: name,
|
||||
|
||||
@@ -357,7 +357,7 @@ func (zm *ZitadelManager) CreateUser(ctx context.Context, email, name, accountID
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pending bool = true
|
||||
pending := true
|
||||
ret := &UserData{
|
||||
Email: email,
|
||||
Name: name,
|
||||
|
||||
@@ -393,7 +393,7 @@ func CreateIndexIfNotExists[T any](ctx context.Context, db *gorm.DB, indexName s
|
||||
return fmt.Errorf("failed to parse model schema: %w", err)
|
||||
}
|
||||
tableName := stmt.Schema.Table
|
||||
dialect := db.Dialector.Name()
|
||||
dialect := db.Name()
|
||||
|
||||
if db.Migrator().HasIndex(&model, indexName) {
|
||||
log.WithContext(ctx).Infof("index %s already exists on table %s", indexName, tableName)
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
const domainPattern = `^(?i)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*[*.a-z]{1,}$`
|
||||
|
||||
var invalidDomainName = errors.New("invalid domain name")
|
||||
var errInvalidDomainName = errors.New("invalid domain name")
|
||||
|
||||
// GetNameServerGroup gets a nameserver group object from account and nameserver group IDs
|
||||
func (am *DefaultAccountManager) GetNameServerGroup(ctx context.Context, accountID, userID, nsGroupID string) (*nbdns.NameServerGroup, error) {
|
||||
@@ -314,7 +314,7 @@ func validateDomain(domain string) error {
|
||||
|
||||
_, valid := dns.IsDomainName(domain)
|
||||
if !valid {
|
||||
return invalidDomainName
|
||||
return errInvalidDomainName
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -158,7 +158,7 @@ func arePostureCheckChangesAffectPeers(ctx context.Context, transaction store.St
|
||||
// validatePostureChecks validates the posture checks.
|
||||
func validatePostureChecks(ctx context.Context, transaction store.Store, accountID string, postureChecks *posture.Checks) error {
|
||||
if err := postureChecks.Validate(); err != nil {
|
||||
return status.Errorf(status.InvalidArgument, "%s", err.Error()) //nolint
|
||||
return status.Errorf(status.InvalidArgument, "%v", err.Error()) //nolint
|
||||
}
|
||||
|
||||
// If the posture check already has an ID, verify its existence in the store.
|
||||
|
||||
@@ -997,9 +997,10 @@ func TestGetAccount_ComprehensiveFieldValidation(t *testing.T) {
|
||||
// Find posture checks by ID
|
||||
var pc1, pc2 *posture.Checks
|
||||
for _, pc := range retrievedAccount.PostureChecks {
|
||||
if pc.ID == postureCheckID1 {
|
||||
switch pc.ID {
|
||||
case postureCheckID1:
|
||||
pc1 = pc
|
||||
} else if pc.ID == postureCheckID2 {
|
||||
case postureCheckID2:
|
||||
pc2 = pc
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/netbirdio/netbird/management/server/types"
|
||||
"github.com/netbirdio/netbird/management/server/util"
|
||||
nbroute "github.com/netbirdio/netbird/route"
|
||||
route2 "github.com/netbirdio/netbird/route"
|
||||
"github.com/netbirdio/netbird/shared/management/status"
|
||||
"github.com/netbirdio/netbird/util/crypt"
|
||||
)
|
||||
@@ -110,12 +109,12 @@ func runLargeTest(t *testing.T, store Store) {
|
||||
AccountID: account.Id,
|
||||
}
|
||||
account.Users[user.Id] = user
|
||||
route := &route2.Route{
|
||||
ID: route2.ID(fmt.Sprintf("network-id-%d", n)),
|
||||
route := &nbroute.Route{
|
||||
ID: nbroute.ID(fmt.Sprintf("network-id-%d", n)),
|
||||
Description: "base route",
|
||||
NetID: route2.NetID(fmt.Sprintf("network-id-%d", n)),
|
||||
NetID: nbroute.NetID(fmt.Sprintf("network-id-%d", n)),
|
||||
Network: netip.MustParsePrefix(netIP.String() + "/24"),
|
||||
NetworkType: route2.IPv4Network,
|
||||
NetworkType: nbroute.IPv4Network,
|
||||
Metric: 9999,
|
||||
Masquerade: false,
|
||||
Enabled: true,
|
||||
@@ -689,7 +688,7 @@ func TestMigrate(t *testing.T) {
|
||||
require.NoError(t, err, "Failed to insert Gob data")
|
||||
|
||||
type route struct {
|
||||
route2.Route
|
||||
nbroute.Route
|
||||
Network netip.Prefix `gorm:"serializer:gob"`
|
||||
PeerGroups []string `gorm:"serializer:gob"`
|
||||
}
|
||||
@@ -698,7 +697,7 @@ func TestMigrate(t *testing.T) {
|
||||
rt := &route{
|
||||
Network: prefix,
|
||||
PeerGroups: []string{"group1", "group2"},
|
||||
Route: route2.Route{ID: "route1"},
|
||||
Route: nbroute.Route{ID: "route1"},
|
||||
}
|
||||
|
||||
err = store.(*SqlStore).db.Save(rt).Error
|
||||
@@ -714,7 +713,7 @@ func TestMigrate(t *testing.T) {
|
||||
require.NoError(t, err, "Failed to delete Gob data")
|
||||
|
||||
prefix = netip.MustParsePrefix("12.0.0.0/24")
|
||||
nRT := &route2.Route{
|
||||
nRT := &nbroute.Route{
|
||||
Network: prefix,
|
||||
ID: "route2",
|
||||
Peer: "peer-id",
|
||||
@@ -3544,13 +3543,13 @@ func TestSqlStore_SaveRoute(t *testing.T) {
|
||||
|
||||
accountID := "bf1c8084-ba50-4ce7-9439-34653001fc3b"
|
||||
|
||||
route := &route2.Route{
|
||||
route := &nbroute.Route{
|
||||
ID: "route-id",
|
||||
AccountID: accountID,
|
||||
Network: netip.MustParsePrefix("10.10.0.0/16"),
|
||||
NetID: "netID",
|
||||
PeerGroups: []string{"routeA"},
|
||||
NetworkType: route2.IPv4Network,
|
||||
NetworkType: nbroute.IPv4Network,
|
||||
Masquerade: true,
|
||||
Metric: 9999,
|
||||
Enabled: true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build !ios
|
||||
// +build !ios
|
||||
|
||||
package testutil
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//go:build ios
|
||||
// +build ios
|
||||
|
||||
package testutil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user