mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 16:02:36 -04:00
Compare commits
3 Commits
v0.25.9
...
debug-goog
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f41e2bd13 | ||
|
|
cb3408a10b | ||
|
|
e3d038da8a |
@@ -904,7 +904,7 @@ components:
|
||||
nameservers:
|
||||
description: Nameserver list
|
||||
minLength: 1
|
||||
maxLength: 2
|
||||
maxLength: 3
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Nameserver'
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -150,19 +152,37 @@ func (gm *GoogleWorkspaceManager) GetAllAccounts() (map[string][]*UserData, erro
|
||||
|
||||
// getAllUsers returns all users in a Google Workspace account filtered by customer ID.
|
||||
func (gm *GoogleWorkspaceManager) getAllUsers() ([]*UserData, error) {
|
||||
var usersLimit int64 = 500
|
||||
if maxUsersLimitEnv := os.Getenv("GOOGLE_WORKSPACE_USERS_LIMIT"); maxUsersLimitEnv != "" {
|
||||
maxUsersLimit, err := strconv.Atoi(maxUsersLimitEnv)
|
||||
if err == nil {
|
||||
log.Debugf("GOOGLE_WORKSPACE_USERS_LIMIT env is set using %d as users limit", maxUsersLimit)
|
||||
usersLimit = int64(maxUsersLimit)
|
||||
}
|
||||
} else {
|
||||
log.Debugf("GOOGLE_WORKSPACE_USERS_LIMIT env is not set using default users limit 500")
|
||||
}
|
||||
|
||||
users := make([]*UserData, 0)
|
||||
pageToken := ""
|
||||
for {
|
||||
call := gm.usersService.List().Customer(gm.CustomerID).MaxResults(500)
|
||||
call := gm.usersService.List().Customer(gm.CustomerID).MaxResults(usersLimit)
|
||||
if pageToken != "" {
|
||||
call.PageToken(pageToken)
|
||||
}
|
||||
|
||||
resp, err := call.Do()
|
||||
if err != nil {
|
||||
log.Debugf("failed to retrieve users from workspace error: %s, http status: %d, headers: %v",
|
||||
err.Error(),
|
||||
resp.HTTPStatusCode,
|
||||
resp.Header,
|
||||
)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugf("fetched %d users from workspace", len(resp.Users))
|
||||
|
||||
for _, user := range resp.Users {
|
||||
users = append(users, parseGoogleWorkspaceUser(user))
|
||||
}
|
||||
|
||||
@@ -255,8 +255,8 @@ func validateNSGroupName(name, nsGroupID string, nsGroupMap map[string]*nbdns.Na
|
||||
|
||||
func validateNSList(list []nbdns.NameServer) error {
|
||||
nsListLenght := len(list)
|
||||
if nsListLenght == 0 || nsListLenght > 2 {
|
||||
return status.Errorf(status.InvalidArgument, "the list of nameservers should be 1 or 2, got %d", len(list))
|
||||
if nsListLenght == 0 || nsListLenght > 3 {
|
||||
return status.Errorf(status.InvalidArgument, "the list of nameservers should be 1 or 3, got %d", len(list))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ func TestCreateNameServerGroup(t *testing.T) {
|
||||
shouldCreate: false,
|
||||
},
|
||||
{
|
||||
name: "Create A NS Group With More Than 2 Nameservers Should Fail",
|
||||
name: "Create A NS Group With More Than 3 Nameservers Should Fail",
|
||||
inputArgs: input{
|
||||
name: "super",
|
||||
description: "super",
|
||||
@@ -238,6 +238,11 @@ func TestCreateNameServerGroup(t *testing.T) {
|
||||
NSType: nbdns.UDPNameServerType,
|
||||
Port: nbdns.DefaultDNSPort,
|
||||
},
|
||||
{
|
||||
IP: netip.MustParseAddr("1.1.4.4"),
|
||||
NSType: nbdns.UDPNameServerType,
|
||||
Port: nbdns.DefaultDNSPort,
|
||||
},
|
||||
},
|
||||
enabled: true,
|
||||
},
|
||||
@@ -457,6 +462,11 @@ func TestSaveNameServerGroup(t *testing.T) {
|
||||
NSType: nbdns.UDPNameServerType,
|
||||
Port: nbdns.DefaultDNSPort,
|
||||
},
|
||||
{
|
||||
IP: netip.MustParseAddr("1.1.4.4"),
|
||||
NSType: nbdns.UDPNameServerType,
|
||||
Port: nbdns.DefaultDNSPort,
|
||||
},
|
||||
}
|
||||
invalidID := "doesntExist"
|
||||
validName := "12345678901234567890qw"
|
||||
|
||||
Reference in New Issue
Block a user