mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 16:49:08 +02:00
Merge remote-tracking branch 'origin/revert/component-types' into revert/component-types
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
@@ -16,11 +16,14 @@ func TestGetAppliedZoneCandidatesViaPgxConnection(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
|
||||
execQuery(t, ctx,
|
||||
`insert into zones (id, account_id, domain, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-1','account-1','test-1.com',true,'["group-one-resource-id"]')`)
|
||||
`insert into zones (id, account_id, domain, enabled, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-1','account-1','test-1.com',true,true,'["group-one-resource-id"]')`)
|
||||
execQuery(t, ctx,
|
||||
`insert into zones (id, account_id, domain, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-2','account-1','test-2.com',false,'["group-two-resources-id"]')`)
|
||||
`insert into zones (id, account_id, domain, enabled, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-2','account-1','test-2.com',true,false,'["group-two-resources-id"]')`)
|
||||
execQuery(t, ctx,
|
||||
`insert into zones (id, account_id, domain, enabled, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-3','account-1','test-3.com',false,true,'["group-one-resource-id"]')`)
|
||||
execQuery(t, ctx,
|
||||
`insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-1','account-1','zone-1','test.test-1.com','A',1800,'1.1.1.1')`)
|
||||
@@ -33,30 +36,45 @@ func TestGetAppliedZoneCandidatesViaPgxConnection(t *testing.T) {
|
||||
execQuery(t, ctx,
|
||||
`insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-4','account-1','zone-2','test2.test-2.com','CNAME',1800,'test3.test-2.com')`)
|
||||
execQuery(t, ctx,
|
||||
`insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-5','account-1','zone-3','test.test-3.com','A',1800,'1.1.1.3')`)
|
||||
|
||||
zoneCandidates, err := conn(t, ctx).GetAppliedZoneCandidates(ctx, "account-1")
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Zone domains and record names are fully qualified, and the zone is served
|
||||
// non-authoritatively — the account-side builder
|
||||
// (types.buildAppliedZoneCandidates) states the same shape, and both feed the
|
||||
// one client-facing map, so the two have to agree.
|
||||
assert.Contains(t, zoneCandidates, networkmap.AppliedZoneCandidate{
|
||||
DistributionGroups: []string{"group-one-resource-id"},
|
||||
Zone: nmdata.CustomZone{
|
||||
Domain: "test-1.com",
|
||||
Domain: "test-1.com.",
|
||||
SearchDomainDisabled: false,
|
||||
NonAuthoritative: true,
|
||||
Records: []nmdata.SimpleRecord{
|
||||
{Name: "test.test-1.com", Type: int(dns.TypeA), Class: "IN", TTL: 1800, RData: "1.1.1.1"},
|
||||
{Name: "test2.test-1.com", Type: int(dns.TypeA), Class: "IN", TTL: 1800, RData: "1.1.1.2"},
|
||||
{Name: "test3.test-1.com", Type: int(dns.TypeCNAME), Class: "IN", TTL: 1800, RData: "test4.test-1.com."},
|
||||
{Name: "test.test-1.com.", Type: int(dns.TypeA), Class: "IN", TTL: 1800, RData: "1.1.1.1"},
|
||||
{Name: "test2.test-1.com.", Type: int(dns.TypeA), Class: "IN", TTL: 1800, RData: "1.1.1.2"},
|
||||
{Name: "test3.test-1.com.", Type: int(dns.TypeCNAME), Class: "IN", TTL: 1800, RData: "test4.test-1.com."},
|
||||
},
|
||||
},
|
||||
})
|
||||
assert.Contains(t, zoneCandidates, networkmap.AppliedZoneCandidate{
|
||||
DistributionGroups: []string{"group-two-resources-id"},
|
||||
Zone: nmdata.CustomZone{
|
||||
Domain: "test-2.com",
|
||||
Domain: "test-2.com.",
|
||||
SearchDomainDisabled: true,
|
||||
NonAuthoritative: true,
|
||||
Records: []nmdata.SimpleRecord{
|
||||
{Name: "test2.test-2.com", Type: int(dns.TypeCNAME), Class: "IN", TTL: 1800, RData: "test3.test-2.com."},
|
||||
{Name: "test2.test-2.com.", Type: int(dns.TypeCNAME), Class: "IN", TTL: 1800, RData: "test3.test-2.com."},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// A zone an admin switched off reaches no peer.
|
||||
for _, candidate := range zoneCandidates {
|
||||
assert.NotEqual(t, "test-3.com.", candidate.Zone.Domain, "disabled zone must not be a candidate")
|
||||
assert.NotEqual(t, "test-3.com", candidate.Zone.Domain, "disabled zone must not be a candidate")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,18 @@ insert into peers (id,account_id,"key", ssh_key, dns_label, extra_dns_labels, us
|
||||
'[1,2]','{"RosenpassEnabled":false,"RosenpassPermissive":false,"ServerSSHAllowed":true,"DisableClientRoutes":false,"DisableServerRoutes":false,"DisableDNS":false,"DisableFirewall":false,"BlockLANAccess":false,"BlockInbound":false,"DisableIPv6":false,"LazyConnectionEnabled":false}',1,
|
||||
'DE','Berlin','"46.201.150.187"');
|
||||
|
||||
insert into zones (id, account_id, domain, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-331','account-33','test-331.com',true,'["33-group-one-resource-id"]');
|
||||
insert into zones (id, account_id, domain, enabled, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-331','account-33','test-331.com',true,true,'["33-group-one-resource-id"]');
|
||||
insert into zones (id, account_id, domain, enabled, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-332','account-33','disabled-331.com',false,true,'["33-group-one-resource-id"]');
|
||||
insert into zones (id, account_id, domain, enabled, enable_search_domain, distribution_groups)
|
||||
VALUES('zone-333','account-33','search-off-331.com',true,false,'["33-group-two-resources-id"]');
|
||||
insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-333','account-33','zone-332','test.disabled-331.com','A',1800,'1.1.1.9');
|
||||
insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-334','account-33','zone-333','test.search-off-331.com','A',1800,'1.1.1.3');
|
||||
insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-335','account-33','zone-333','alias.search-off-331.com','CNAME',1800,'test.search-off-331.com');
|
||||
insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
VALUES('record-331','account-33','zone-331','test.test-331.com','A',1800,'1.1.1.1');
|
||||
insert into records (id, account_id, zone_id, name, type, ttl, content)
|
||||
|
||||
@@ -493,17 +493,17 @@
|
||||
"33-group-one-resource-id"
|
||||
],
|
||||
"Zone": {
|
||||
"Domain": "test-331.com",
|
||||
"Domain": "test-331.com.",
|
||||
"Records": [
|
||||
{
|
||||
"Name": "test.test-331.com",
|
||||
"Name": "test.test-331.com.",
|
||||
"Type": 1,
|
||||
"Class": "IN",
|
||||
"TTL": 1800,
|
||||
"RData": "1.1.1.1"
|
||||
},
|
||||
{
|
||||
"Name": "test2.test-331.com",
|
||||
"Name": "test2.test-331.com.",
|
||||
"Type": 1,
|
||||
"Class": "IN",
|
||||
"TTL": 1800,
|
||||
@@ -511,7 +511,33 @@
|
||||
}
|
||||
],
|
||||
"SearchDomainDisabled": false,
|
||||
"NonAuthoritative": false
|
||||
"NonAuthoritative": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"DistributionGroups": [
|
||||
"33-group-two-resources-id"
|
||||
],
|
||||
"Zone": {
|
||||
"Domain": "search-off-331.com.",
|
||||
"Records": [
|
||||
{
|
||||
"Name": "test.search-off-331.com.",
|
||||
"Type": 1,
|
||||
"Class": "IN",
|
||||
"TTL": 1800,
|
||||
"RData": "1.1.1.3"
|
||||
},
|
||||
{
|
||||
"Name": "alias.search-off-331.com.",
|
||||
"Type": 5,
|
||||
"Class": "IN",
|
||||
"TTL": 1800,
|
||||
"RData": "test.search-off-331.com."
|
||||
}
|
||||
],
|
||||
"SearchDomainDisabled": true,
|
||||
"NonAuthoritative": true
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -31,12 +31,13 @@ const EnvUpdateGoldenData = "NMAP_UPDATE_GOLDEN_DATA"
|
||||
|
||||
func TestGetNetworkMapData(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
ctrl := gomock.NewController(t)
|
||||
|
||||
extraSettingsManager := settings.NewMockManager(ctrl)
|
||||
// The two mocks are generated by different mock frameworks, so each needs a
|
||||
// controller of its own kind.
|
||||
extraSettingsManager := settings.NewMockManager(gomock.NewController(t))
|
||||
extraSettingsManager.EXPECT().GetExtraSettings(gomock.Any(), gomock.Any()).Return(&types.ExtraSettings{}, nil)
|
||||
|
||||
peerValidators := integrated_validator.NewMockIntegratedValidator(ctrl)
|
||||
peerValidators := integrated_validator.NewMockIntegratedValidator(gomock.NewController(t))
|
||||
peerValidators.EXPECT().GetValidatedPeers(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(
|
||||
map[string]struct{}{
|
||||
"peer-id-1": {},
|
||||
|
||||
Reference in New Issue
Block a user