-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f146121
commit 320961f
Showing
1 changed file
with
88 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,86 +298,96 @@ func TestInventoryAPIHTTP_K8SClusterLifecycle(t *testing.T) { | |
|
||
_, err = client.K8sClusterService.UpdateK8SCluster(context.Background(), &updateRequest, opts...) | ||
assert.NoError(t, err) | ||
|
||
deleteRequest := resources.DeleteK8SClusterRequest{ | ||
ReporterData: &resources.ReporterData{ | ||
ReporterInstanceId: "[email protected]", | ||
ReporterType: resources.ReporterData_ACM, | ||
ConsoleHref: "www.example.com", | ||
ApiHref: "www.example.com", | ||
LocalResourceId: "01234", | ||
ReporterVersion: "0.1", | ||
}, | ||
} | ||
_, err = client.K8sClusterService.DeleteK8SCluster(context.Background(), &deleteRequest, opts...) | ||
assert.NoError(t, err) | ||
} | ||
|
||
// | ||
//func TestInventoryAPIHTTP_K8SPolicy_CreateK8SPolicy(t *testing.T) { | ||
// t.Parallel() | ||
// c := v1beta1.NewConfig( | ||
// v1beta1.WithHTTPUrl(inventoryapi_http_url), | ||
// v1beta1.WithTLSInsecure(insecure), | ||
// v1beta1.WithHTTPTLSConfig(tlsConfig), | ||
// ) | ||
// client, err := v1beta1.NewHttpClient(context.Background(), c) | ||
// if err != nil { | ||
// t.Error(err) | ||
// } | ||
// | ||
// request := resources.CreateK8SPolicyRequest{ | ||
// K8SPolicy: &resources.K8SPolicy{ | ||
// Metadata: &resources.Metadata{ | ||
// ResourceType: "k8s-policy", | ||
// WorkspaceId: "workspace2", | ||
// OrgId: "", | ||
// }, | ||
// ResourceData: &resources.K8SPolicyDetail{ | ||
// Disabled: false, | ||
// Severity: resources.K8SPolicyDetail_HIGH, | ||
// }, | ||
// ReporterData: &resources.ReporterData{ | ||
// ReporterInstanceId: "[email protected]", | ||
// ReporterType: resources.ReporterData_OCM, | ||
// ConsoleHref: "www.example.com", | ||
// ApiHref: "www.example.com", | ||
// LocalResourceId: "012345", | ||
// ReporterVersion: "0.1", | ||
// }, | ||
// }, | ||
// } | ||
// opts := getCallOptions() | ||
// _, err = client.PolicyServiceClient.CreateK8SPolicy(context.Background(), &request, opts...) | ||
// assert.NoError(t, err) | ||
// | ||
//} | ||
// | ||
//func TestInventoryAPIHTTP_K8SPolicy_UpdateK8SPolicy(t *testing.T) { | ||
// t.Parallel() | ||
// c := v1beta1.NewConfig( | ||
// v1beta1.WithHTTPUrl(inventoryapi_http_url), | ||
// v1beta1.WithTLSInsecure(insecure), | ||
// v1beta1.WithHTTPTLSConfig(tlsConfig), | ||
// ) | ||
// client, err := v1beta1.NewHttpClient(context.Background(), c) | ||
// if err != nil { | ||
// t.Error(err) | ||
// } | ||
// | ||
// request := resources.UpdateK8SPolicyRequest{ | ||
// K8SPolicy: &resources.K8SPolicy{ | ||
// Metadata: &resources.Metadata{ | ||
// ResourceType: "k8s-policy", | ||
// WorkspaceId: "workspace2", | ||
// OrgId: "", | ||
// }, | ||
// ResourceData: &resources.K8SPolicyDetail{ | ||
// Disabled: false, | ||
// Severity: resources.K8SPolicyDetail_HIGH, | ||
// }, | ||
// ReporterData: &resources.ReporterData{ | ||
// ReporterInstanceId: "[email protected]", | ||
// ReporterType: resources.ReporterData_OCM, | ||
// ConsoleHref: "www.example.com", | ||
// ApiHref: "www.example.com", | ||
// LocalResourceId: "012345", | ||
// ReporterVersion: "0.1", | ||
// }, | ||
// }, | ||
// } | ||
// opts := getCallOptions() | ||
// _, err = client.PolicyServiceClient.UpdateK8SPolicy(context.Background(), &request, opts...) | ||
// assert.NoError(t, err) | ||
// | ||
//} | ||
func TestInventoryAPIHTTP_K8SPolicyLifecycle(t *testing.T) { | ||
t.Parallel() | ||
c := v1beta1.NewConfig( | ||
v1beta1.WithHTTPUrl(inventoryapi_http_url), | ||
v1beta1.WithTLSInsecure(insecure), | ||
v1beta1.WithHTTPTLSConfig(tlsConfig), | ||
) | ||
client, err := v1beta1.NewHttpClient(context.Background(), c) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
request := resources.CreateK8SPolicyRequest{ | ||
K8SPolicy: &resources.K8SPolicy{ | ||
Metadata: &resources.Metadata{ | ||
ResourceType: "k8s-policy", | ||
WorkspaceId: "workspace2", | ||
OrgId: "", | ||
}, | ||
ResourceData: &resources.K8SPolicyDetail{ | ||
Disabled: false, | ||
Severity: resources.K8SPolicyDetail_HIGH, | ||
}, | ||
ReporterData: &resources.ReporterData{ | ||
ReporterInstanceId: "[email protected]", | ||
ReporterType: resources.ReporterData_OCM, | ||
ConsoleHref: "www.example.com", | ||
ApiHref: "www.example.com", | ||
LocalResourceId: "012345", | ||
ReporterVersion: "0.1", | ||
}, | ||
}, | ||
} | ||
opts := getCallOptions() | ||
_, err = client.PolicyServiceClient.CreateK8SPolicy(context.Background(), &request, opts...) | ||
assert.NoError(t, err) | ||
|
||
updateRequest := resources.UpdateK8SPolicyRequest{ | ||
K8SPolicy: &resources.K8SPolicy{ | ||
Metadata: &resources.Metadata{ | ||
ResourceType: "k8s-policy", | ||
WorkspaceId: "workspace2", | ||
OrgId: "", | ||
}, | ||
ResourceData: &resources.K8SPolicyDetail{ | ||
Disabled: true, | ||
Severity: resources.K8SPolicyDetail_LOW, | ||
}, | ||
ReporterData: &resources.ReporterData{ | ||
ReporterInstanceId: "[email protected]", | ||
ReporterType: resources.ReporterData_OCM, | ||
ConsoleHref: "www.example.com", | ||
ApiHref: "www.example.com", | ||
LocalResourceId: "012345", | ||
ReporterVersion: "0.1", | ||
}, | ||
}, | ||
} | ||
|
||
_, err = client.PolicyServiceClient.UpdateK8SPolicy(context.Background(), &updateRequest, opts...) | ||
assert.NoError(t, err) | ||
|
||
deleteRequest := resources.DeleteK8SPolicyRequest{ | ||
ReporterData: &resources.ReporterData{ | ||
ReporterInstanceId: "[email protected]", | ||
ReporterType: resources.ReporterData_OCM, | ||
ConsoleHref: "www.example.com", | ||
ApiHref: "www.example.com", | ||
LocalResourceId: "012345", | ||
ReporterVersion: "0.1", | ||
}, | ||
} | ||
_, err = client.PolicyServiceClient.DeleteK8SPolicy(context.Background(), &deleteRequest, opts...) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func getCallOptions() []http.CallOption { | ||
var opts []http.CallOption | ||
|