Skip to content

Commit

Permalink
add notifications test case to e2e tests (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam0Brien authored Feb 17, 2025
1 parent 156949c commit d712729
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/project-kessel/inventory-client-go v0.0.0-20240918112335-d9c72f85b234
github.com/project-kessel/inventory-client-go v0.0.0-20250213094514-4b90870d8dcf
github.com/project-kessel/relations-api v0.0.0-20241021205601-90db9ba90a73
github.com/prometheus/client_golang v1.20.5
github.com/redhatinsights/app-common-go v1.6.8
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b h1:0LFwY6Q3g
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/project-kessel/inventory-client-go v0.0.0-20240918112335-d9c72f85b234 h1:Ms0bb3nq9slmvRIRhPxTocC/nVJtUrRDlEnmcXgP7as=
github.com/project-kessel/inventory-client-go v0.0.0-20240918112335-d9c72f85b234/go.mod h1:ghVJESku3BJcPp3A8RTuHIErM0RptidPKoi0xGTlgrk=
github.com/project-kessel/inventory-client-go v0.0.0-20250213094514-4b90870d8dcf h1:RIKxvHBg98bak8Z58gNOgYbBZsOOLYKNRpLVSNhdNA8=
github.com/project-kessel/inventory-client-go v0.0.0-20250213094514-4b90870d8dcf/go.mod h1:ghVJESku3BJcPp3A8RTuHIErM0RptidPKoi0xGTlgrk=
github.com/project-kessel/relations-api v0.0.0-20241021205601-90db9ba90a73 h1:w/VpkTj8lEw4/EoCVjMj7Yiq3qI6jAPJ35vEWpiMKdk=
github.com/project-kessel/relations-api v0.0.0-20241021205601-90db9ba90a73/go.mod h1:eFvW2RvCRuvjpfpovZHlgw7JLQLIU0G0GVX0SXd7FUE=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
Expand Down
63 changes: 63 additions & 0 deletions test/e2e/inventory_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,69 @@ func TestInventoryAPIHTTP_K8SPolicyLifecycle(t *testing.T) {
assert.NoError(t, err, "Failed to delete K8sPolicy")
}

func TestInventoryAPIHTTP_NotificationsIntegrationLifecycle(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.Fatal("Failed to create HTTP client: ", err)
}

createRequest := resources.CreateNotificationsIntegrationRequest{
Integration: &resources.NotificationsIntegration{
Metadata: &resources.Metadata{
ResourceType: "notifications/integration",
WorkspaceId: "ws-456",
},
ReporterData: &resources.ReporterData{
ReporterType: resources.ReporterData_NOTIFICATIONS,
ConsoleHref: "https://console.notifications.example.com",
ApiHref: "https://api.notifications.example.com",
LocalResourceId: "notifications-001",
ReporterVersion: "1.0",
},
},
}

opts := getCallOptions()
_, err = client.NotificationIntegrationClient.CreateNotificationsIntegration(context.Background(), &createRequest, opts...)
assert.NoError(t, err, "Failed to create Notifications Integration")

updateRequest := resources.UpdateNotificationsIntegrationRequest{
Integration: &resources.NotificationsIntegration{
Metadata: &resources.Metadata{
ResourceType: "notifications/integration",
WorkspaceId: "ws-789",
},
ReporterData: &resources.ReporterData{
ReporterType: resources.ReporterData_NOTIFICATIONS,
ConsoleHref: "https://console.notifications.example.com",
ApiHref: "https://api.notifications.example.com",
LocalResourceId: "notifications-001",
ReporterVersion: "1.1",
},
},
}

_, err = client.NotificationIntegrationClient.UpdateNotificationsIntegration(context.Background(), &updateRequest, opts...)
assert.NoError(t, err, "Failed to update Notifications Integration")

deleteRequest := resources.DeleteNotificationsIntegrationRequest{
ReporterData: &resources.ReporterData{
ReporterType: resources.ReporterData_NOTIFICATIONS,
LocalResourceId: "notifications-001",
},
}

_, err = client.NotificationIntegrationClient.DeleteNotificationsIntegration(context.Background(), &deleteRequest, opts...)
assert.NoError(t, err, "Failed to delete Notifications Integration")
}

func TestInventoryAPIHTTP_K8SPolicy_is_propagated_to_K8sClusterLifecycle(t *testing.T) {
t.Parallel()
c := v1beta1.NewConfig(
Expand Down

0 comments on commit d712729

Please sign in to comment.