This commit is contained in:
asteam
2025-11-14 17:38:59 +03:00
parent 562b6019d0
commit 0bf073da93
149 changed files with 11080 additions and 38 deletions

View File

@@ -26,6 +26,13 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/acsgroups"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/adrspools"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/defsecpolicies"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/segments"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/secpolicies"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/secpolicies/rule"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/logicalports"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/routers"
account_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
audit_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
@@ -50,6 +57,10 @@ import (
trunk_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/trunk"
vins_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
zone_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/zone"
extnet_sdn "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/extnet"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/flips"
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn/netobjgroups"
)
// TestGetListCloudAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods
@@ -901,9 +912,9 @@ func TestGetListSDNAPI(t *testing.T) {
// Users AccessGroups
// list
listAcsGroups, _ := client.SDN().AccessGroups().List(context.Background(), acsgroups.ListGroupsRequest{})
if len(listAcsGroups.AccessGroups) > 0 {
id := listAcsGroups.AccessGroups[0].ID
listGroups, _ := client.SDN().AccessGroups().List(context.Background(), acsgroups.ListGroupsRequest{})
if len(listGroups.AccessGroups) > 0 {
id := listGroups.AccessGroups[0].ID
bytes, err = client.SDN().AccessGroups().UserListRaw(context.Background(), acsgroups.UsersListRequest{AccessGroupID: id})
if err != nil {
t.Error(err)
@@ -913,6 +924,196 @@ func TestGetListSDNAPI(t *testing.T) {
t.Errorf("Can not test users get because acs groups list is empty")
}
// DefaultSecurityPolicies
// List
bytes, err = client.SDN().DefaultSecurityPolicies().ListRaw(context.Background(), defsecpolicies.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("default security policies list", bytes, defsecpolicies.SecurityPoliciesList{}, t)
// Address Pools
// List
bytes, err = client.SDN().AddressPools().ListRaw(context.Background(), adrspools.ListAddressPoolsRequest{})
if err != nil {
t.Error(err)
}
getResult("Address pools list", bytes, adrspools.AddressPoolsList{}, t)
// Get
listStoragePolicies, _ := client.SDN().AddressPools().List(context.Background(), adrspools.ListAddressPoolsRequest{})
if len(listStoragePolicies.Pools) > 0 {
id := listStoragePolicies.Pools[0].ID
bytes, err = client.SDN().AddressPools().GetRaw(context.Background(), adrspools.GetRequest{ID: id})
if err != nil {
t.Error(err)
}
getResult("Address pools get", bytes, adrspools.NetworkAddressPool{}, t)
} else {
t.Errorf("Can not test address pools get because list is empty")
}
// Security policies
// List
bytes, err = client.SDN().SecurityPolicies().ListRaw(context.Background(), secpolicies.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Security policies list", bytes, secpolicies.SecurityPolicyList{}, t)
// Get
listPolicies, _ := client.SDN().SecurityPolicies().List(context.Background(), secpolicies.ListRequest{})
if len(listPolicies) > 0 {
id := listPolicies[0].ID
bytes, err = client.SDN().SecurityPolicies().GetRaw(context.Background(), secpolicies.GetRequest{ID: id})
if err != nil {
t.Error(err)
}
getResult("Security policies get", bytes, secpolicies.SecurityPolicySummary{}, t)
} else {
t.Errorf("Can not test security policies get because list is empty")
}
// rule List
bytes, err = client.SDN().SecurityPolicies().Rule().ListRaw(context.Background(), rule.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Security policy rule list", bytes, rule.SecurityRulesList{}, t)
// Get
listRules, _ := client.SDN().SecurityPolicies().Rule().List(context.Background(), rule.ListRequest{})
if len(listRules) > 0 {
id := listRules[0].ID
securityPolicyID := listRules[0].SecurityPolicyID
bytes, err = client.SDN().SecurityPolicies().Rule().GetRaw(context.Background(), rule.GetRequest{
SecurityPolicyID: securityPolicyID,
SecurityRuleID: id})
if err != nil {
t.Error(err)
}
getResult("Security policy rule get", bytes, rule.SecurityRule{}, t)
} else {
t.Errorf("Can not test the security policy rules get because list is empty")
}
// ExtNet
// List
bytes, err = client.SDN().ExtNet().ListRaw(context.Background(), extnet_sdn.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("ExtNet list", bytes, extnet_sdn.ListExtNet{}, t)
// Get
listExtNet, _ := client.SDN().ExtNet().List(context.Background(), extnet_sdn.ListRequest{})
if len(listExtNet) > 0 {
id := listExtNet[0].ID
bytes, err = client.SDN().ExtNet().GetRaw(context.Background(), extnet_sdn.GetRequest{ExtNetID: id})
if err != nil {
t.Error(err)
}
getResult("ExtNet get", bytes, extnet_sdn.ExternalNetworkResponse{}, t)
} else {
t.Errorf("Can not test ExtNet get because listExtNet list is empty")
}
// Network object groups
// List
bytes, err = client.SDN().NetworkObjectGroups().ListRaw(context.Background(), netobjgroups.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("NetObjGroup list", bytes, netobjgroups.NetObjGroupList{}, t)
// Get
listNetObjGroups, _ := client.SDN().NetworkObjectGroups().List(context.Background(), netobjgroups.ListRequest{})
if len(listNetObjGroups.Objects) > 0 {
id := listNetObjGroups.Objects[0].ID
bytes, err = client.SDN().NetworkObjectGroups().GetRaw(context.Background(), netobjgroups.GetRequest{NetObjGroupID: id})
if err != nil {
t.Error(err)
}
getResult("NetObjGroup get", bytes, netobjgroups.RecordNetObjGroup{}, t)
} else {
t.Errorf("Can not test NetObjGroup get because listNetObjGroups list is empty")
}
// Segment
// List
bytes, err = client.SDN().Segments().ListRaw(context.Background(), segments.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Segments list", bytes, segments.ListSegment{}, t)
// Get
listSegments, _ := client.SDN().Segments().List(context.Background(), segments.ListRequest{})
if len(listSegments) > 0 {
id := listSegments[0].ID
bytes, err = client.SDN().Segments().GetRaw(context.Background(), segments.GetRequest{SegmentID: id})
if err != nil {
t.Error(err)
}
getResult("Segments get", bytes, adrspools.NetworkAddressPool{}, t)
} else {
t.Errorf("Can not test segments get because list is empty")
}
// FloatingIPs
// List
bytes, err = client.SDN().FloatingIPs().ListRaw(context.Background(), flips.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("FloatingIPs list", bytes, flips.FloatingIPsList{}, t)
// Get
listFloatingIPs, _ := client.SDN().FloatingIPs().List(context.Background(), flips.ListRequest{})
if len(listFloatingIPs.Objects) > 0 {
id := listFloatingIPs.Objects[0].ID
bytes, err = client.SDN().FloatingIPs().GetRaw(context.Background(), flips.GetRequest{FloatingIPID: id})
if err != nil {
t.Error(err)
}
getResult("FloatingIPs get", bytes, flips.RecordFloatingIP{}, t)
} else {
t.Errorf("Can not test FloatingIPs get because listFloatingIPs list is empty")
}
// logical ports
// List
bytes, err = client.SDN().LogicalPorts().ListRaw(context.Background(), logicalports.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Logical ports list", bytes, logicalports.LogicalPortsList{}, t)
// Get
listLP, _ := client.SDN().LogicalPorts().List(context.Background(), logicalports.ListRequest{})
if len(listLP.Ports) > 0 {
id := listStoragePolicies.Pools[0].ID
bytes, err = client.SDN().LogicalPorts().GetRaw(context.Background(), logicalports.GetRequest{ID: id})
if err != nil {
t.Error(err)
}
getResult("Logical port get", bytes, logicalports.LogicalPort{}, t)
} else {
t.Errorf("Can not test logical ports get because list is empty")
}
// Routers
// List
bytes, err = client.SDN().Routers().ListRaw(context.Background(), routers.ListRequest{})
if err != nil {
t.Error(err)
}
getResult("Routers list", bytes, routers.RoutersList{}, t)
// Get
routerList, _ := client.SDN().Routers().List(context.Background(), routers.ListRequest{})
if len(routerList) > 0 {
id := routerList[0].ID
bytes, err = client.SDN().Routers().GetRaw(context.Background(), routers.GetRequest{ID: id})
if err != nil {
t.Error(err)
}
getResult("Router get", bytes, routers.RoutersModel{}, t)
} else {
t.Errorf("Can not test routers get because routerList list is empty")
}
}
// TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests
@@ -949,7 +1150,7 @@ func TestGetAllPaths(t *testing.T) {
for _, r := range missingUrls {
errorText += fmt.Sprintln(r)
}
t.Errorf(errorText)
t.Errorf("\n%s\n", errorText)
}
deprecatedUrls := getDeprecatedDecortUrls(jsonUrls, decortUrls)
@@ -958,7 +1159,7 @@ func TestGetAllPaths(t *testing.T) {
for _, r := range deprecatedUrls {
errorText += fmt.Sprintln(r)
}
t.Errorf(errorText)
t.Errorf("\n%s\n", errorText)
}
caTestUrls := getRequestsMapCloudAPI()
@@ -987,7 +1188,7 @@ func TestGetAllPaths(t *testing.T) {
for _, r := range missingUrls {
errorText += fmt.Sprintln(r)
}
t.Errorf(errorText)
t.Errorf("\n%s\n", errorText)
}
deprecatedUrls = getDeprecatedDecortUrls(jsonUrls, urlsInTest)
@@ -996,7 +1197,7 @@ func TestGetAllPaths(t *testing.T) {
for _, r := range deprecatedUrls {
errorText += fmt.Sprintln(r)
}
t.Errorf(errorText)
t.Errorf("\n%s\n", errorText)
}
}