Skip to content

Commit

Permalink
[v16] Include SAML IdP service provider preset value in unified res…
Browse files Browse the repository at this point in the history
…ource view response (#43610)

* include SAML IdP service provider preset value in unified resource response

* reduce empty lines
  • Loading branch information
flyinghermit authored Jun 27, 2024
1 parent 936631a commit 8885a1d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
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

0 comments on commit 8885a1d

Please sign in to comment.