From a230263d4bfb32ae9194eeffbbb402dab6fa6a1c Mon Sep 17 00:00:00 2001 From: flyinghermit Date: Mon, 24 Jun 2024 18:02:35 -0400 Subject: [PATCH 1/2] include SAML IdP service provider preset value in unified resource response --- lib/web/ui/app.go | 4 +++ lib/web/ui/app_test.go | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/lib/web/ui/app.go b/lib/web/ui/app.go index 22e336a63d476..2b386ed80766c 100644 --- a/lib/web/ui/app.go +++ b/lib/web/ui/app.go @@ -56,6 +56,9 @@ type App struct { UserGroups []UserGroupAndDescription `json:"userGroups,omitempty"` // SAMLApp if true, indicates that the app is a SAML Application (SAML IdP Service Provider) SAMLApp bool `json:"samlApp,omitempty"` + // SAMLAppPreset is the preset value of SAML IdP service provider. The SAML service provider + // preset value is used to process custom configuration for the service provider. + SAMLAppPreset string `json:"samlAppPreset,omitempty"` // RequireRequest indicates if a returned resource is only accessible after an access request RequiresRequest bool `json:"requiresRequest,omitempty"` // Integration is the integration name that must be used to access this Application. @@ -163,6 +166,7 @@ func MakeAppTypeFromSAMLApp(app types.SAMLIdPServiceProvider, c MakeAppsConfig) ClusterID: c.AppClusterName, FriendlyName: types.FriendlyName(app), SAMLApp: true, + SAMLAppPreset: app.GetPreset(), RequiresRequest: c.RequiresRequest, } diff --git a/lib/web/ui/app_test.go b/lib/web/ui/app_test.go index 4ddc5d8b774b2..bbddbaf1ee176 100644 --- a/lib/web/ui/app_test.go +++ b/lib/web/ui/app_test.go @@ -223,6 +223,61 @@ func newApp(t *testing.T, name, publicAddr, description string, labels map[strin return app } +func TestMakeAppTypeFromSAMLApp(t *testing.T) { + tests := []struct { + name string + sp types.SAMLIdPServiceProviderV1 + appsToUserGroups map[string]types.UserGroups + expected App + }{ + { + name: "empty", + expected: App{ + Kind: types.KindApp, + Name: "", + Description: "SAML Application", + PublicAddr: "", + Labels: []Label{}, + SAMLApp: true, + SAMLAppPreset: "", + }, + }, + { + name: "saml idp service provider", + sp: types.SAMLIdPServiceProviderV1{ + ResourceHeader: types.ResourceHeader{ + Metadata: types.Metadata{ + Name: "test_app", + }, + }, + Spec: types.SAMLIdPServiceProviderSpecV1{ + Preset: "test_preset", + }, + }, + expected: App{ + Kind: types.KindApp, + Name: "test_app", + Description: "SAML Application", + PublicAddr: "", + Labels: []Label{}, + SAMLApp: true, + SAMLAppPreset: "test_preset", + }, + }, + } + + for _, test := range tests { + test := test + t.Run(test.name, func(t *testing.T) { + t.Parallel() + + apps := MakeAppTypeFromSAMLApp(&test.sp, MakeAppsConfig{}) + + require.Empty(t, cmp.Diff(test.expected, apps)) + }) + } +} + // createAppServerOrSPFromApp returns a AppServerOrSAMLIdPServiceProvider given an App. // //nolint:staticcheck // SA1019. Kept to be deleted along with the API in 16.0. From 0355247d4343793e61ad5dc6a519f58bb32966ba Mon Sep 17 00:00:00 2001 From: flyinghermit Date: Mon, 24 Jun 2024 18:06:43 -0400 Subject: [PATCH 2/2] reduce empty lines --- lib/web/ui/app_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/web/ui/app_test.go b/lib/web/ui/app_test.go index bbddbaf1ee176..e63485935dd97 100644 --- a/lib/web/ui/app_test.go +++ b/lib/web/ui/app_test.go @@ -270,9 +270,7 @@ func TestMakeAppTypeFromSAMLApp(t *testing.T) { test := test t.Run(test.name, func(t *testing.T) { t.Parallel() - apps := MakeAppTypeFromSAMLApp(&test.sp, MakeAppsConfig{}) - require.Empty(t, cmp.Diff(test.expected, apps)) }) }