Skip to content
Draft
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
6 changes: 6 additions & 0 deletions internal/shared/types/app_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type AppFeatures struct {
Search *Search `json:"search,omitempty" yaml:"search,flow,omitempty"`
RichPreviews *RichPreviews `json:"rich_previews,omitempty" yaml:"rich_previews,flow,omitempty"`
CodeChannels *CodeChannels `json:"code_channels,omitempty" yaml:"code_channels,flow,omitempty"`
UserConnections *UserConnections `json:"user_connections,omitempty" yaml:"user_connections,flow,omitempty"`
}

type RichPreviews struct {
Expand Down Expand Up @@ -300,6 +301,11 @@ type CodeChannels struct {
SlashCommandURL string `json:"slash_command_url,omitempty" yaml:"slash_command_url,omitempty"`
}

type UserConnections struct {
IsEnabled bool `json:"is_enabled" yaml:"is_enabled"`
AuthHosts []string `json:"auth_hosts" yaml:"auth_hosts,flow"`
}

// Workflow defines the structure of a workflow in the app manifest.
type Workflow struct {
Title string `json:"title" yaml:"title"`
Expand Down
61 changes: 61 additions & 0 deletions internal/shared/types/app_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,30 @@ func Test_AppManifest_AppFeatures(t *testing.T) {
},
want: `{"app_home":{},"bot_user":{"display_name":"coding_agent"},"code_channels":{"enabled":false}}`,
},
"includes user connections when provided": {
features: AppFeatures{
BotUser: BotUser{
DisplayName: "connector",
},
UserConnections: &UserConnections{
IsEnabled: true,
AuthHosts: []string{"example.com", "auth.example.com"},
},
},
want: `{"app_home":{},"bot_user":{"display_name":"connector"},"user_connections":{"is_enabled":true,"auth_hosts":["example.com","auth.example.com"]}}`,
},
"serializes user connections disabled explicitly": {
features: AppFeatures{
BotUser: BotUser{
DisplayName: "connector",
},
UserConnections: &UserConnections{
IsEnabled: false,
AuthHosts: []string{"example.com"},
},
},
want: `{"app_home":{},"bot_user":{"display_name":"connector"},"user_connections":{"is_enabled":false,"auth_hosts":["example.com"]}}`,
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
Expand All @@ -283,6 +307,43 @@ func Test_AppManifest_AppFeatures(t *testing.T) {
}
}

func Test_AppManifest_AppFeatures_UserConnections(t *testing.T) {
tests := map[string]struct {
manifestJSON string
expected *UserConnections
}{
"undefined user connections are omitted": {
manifestJSON: `{"display_information":{"name":"connector"},"features":{"app_home":{},"bot_user":{"display_name":"connector"}}}`,
expected: nil,
},
"enabled user connections are preserved": {
manifestJSON: `{"display_information":{"name":"connector"},"features":{"app_home":{},"bot_user":{"display_name":"connector"},"user_connections":{"is_enabled":true,"auth_hosts":["example.com","auth.example.com"]}}}`,
expected: &UserConnections{
IsEnabled: true,
AuthHosts: []string{"example.com", "auth.example.com"},
},
},
"disabled user connections keep their auth hosts": {
manifestJSON: `{"display_information":{"name":"connector"},"features":{"app_home":{},"bot_user":{"display_name":"connector"},"user_connections":{"is_enabled":false,"auth_hosts":["example.com"]}}}`,
expected: &UserConnections{
IsEnabled: false,
AuthHosts: []string{"example.com"},
},
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
var manifest AppManifest
err := json.Unmarshal([]byte(tc.manifestJSON), &manifest)
require.NoError(t, err)
assert.Equal(t, tc.expected, manifest.Features.UserConnections)
actualJSON, err := json.Marshal(manifest)
require.NoError(t, err)
assert.JSONEq(t, tc.manifestJSON, string(actualJSON))
})
}
}

func Test_AppManifest_AppSettings_SiwsLinks(t *testing.T) {
expectedSiws := SiwsLinks{
InitiateURI: "an initiate uri",
Expand Down
Loading