Skip to content
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
6 changes: 4 additions & 2 deletions internal/shared/types/app_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ type ManifestInteractivity struct {

// ManifestScopes
type ManifestScopes struct {
Bot []string `json:"bot,omitempty" yaml:"bot,flow,omitempty"`
User []string `json:"user,omitempty" yaml:"user,flow,omitempty"`
Bot []string `json:"bot,omitempty" yaml:"bot,flow,omitempty"`
BotOptional []string `json:"bot_optional,omitempty" yaml:"bot_optional,flow,omitempty"`
User []string `json:"user,omitempty" yaml:"user,flow,omitempty"`
UserOptional []string `json:"user_optional,omitempty" yaml:"user_optional,flow,omitempty"`
}

// ManifestShortcutsItem
Expand Down
56 changes: 56 additions & 0 deletions internal/shared/types/app_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,62 @@ func Test_AppManifest_AppSettings_IncomingWebhooks(t *testing.T) {
}
}

func Test_AppManifest_OAuthConfig_Scopes(t *testing.T) {
tests := map[string]struct {
oauthConfig *OAuthConfig
expectedJSON string
}{
"undefined scopes are omitted": {
oauthConfig: &OAuthConfig{},
expectedJSON: `{}`,
},
"empty scopes are included": {
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{}},
expectedJSON: `{"scopes":{}}`,
},
"bot scopes are included": {
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
Bot: []string{"chat:write", "channels:read"},
}},
expectedJSON: `{"scopes":{"bot":["chat:write","channels:read"]}}`,
},
"user scopes are included": {
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
User: []string{"users:read"},
}},
expectedJSON: `{"scopes":{"user":["users:read"]}}`,
},
"bot optional scopes are included": {
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
BotOptional: []string{"channels:history"},
}},
expectedJSON: `{"scopes":{"bot_optional":["channels:history"]}}`,
},
"user optional scopes are included": {
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
UserOptional: []string{"users:read.email"},
}},
expectedJSON: `{"scopes":{"user_optional":["users:read.email"]}}`,
},
"all scope types are included": {
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
Bot: []string{"chat:write"},
BotOptional: []string{"channels:history"},
User: []string{"users:read"},
UserOptional: []string{"users:read.email"},
}},
expectedJSON: `{"scopes":{"bot":["chat:write"],"bot_optional":["channels:history"],"user":["users:read"],"user_optional":["users:read.email"]}}`,
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
actualJSON, err := json.Marshal(tc.oauthConfig)
require.NoError(t, err)
assert.Equal(t, tc.expectedJSON, string(actualJSON))
})
}
}

func Test_AppManifest_AppSettings_FunctionRuntime(t *testing.T) {
tests := map[string]struct {
settings *AppSettings
Expand Down
Loading