Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include SAML IdP service provider preset value in unified resource view response #43446

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/web/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
}

Expand Down
53 changes: 53 additions & 0 deletions lib/web/ui/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,59 @@ 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.
Expand Down
Loading