Skip to content

Commit 6432b78

Browse files
authored
Merge branch 'main' into mwbrooks-snyk
2 parents d1940c7 + e1112eb commit 6432b78

4 files changed

Lines changed: 63 additions & 5 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
1919
github.com/oliamb/cutter v0.2.2
2020
github.com/opentracing/opentracing-go v1.2.0
21-
github.com/pelletier/go-toml/v2 v2.3.0
21+
github.com/pelletier/go-toml/v2 v2.3.1
2222
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
2323
github.com/pkg/errors v0.9.1
2424
github.com/radovskyb/watcher v1.0.7

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,8 @@ github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwp
10191019
github.com/pborman/getopt v0.0.0-20180811024354-2b5b3bfb099b/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
10201020
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
10211021
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
1022-
github.com/pelletier/go-toml/v2 v2.3.0 h1:k59bC/lIZREW0/iVaQR8nDHxVq8OVlIzYCOJf421CaM=
1023-
github.com/pelletier/go-toml/v2 v2.3.0/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
1022+
github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc=
1023+
github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
10241024
github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
10251025
github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
10261026
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=

internal/shared/types/app_manifest.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ type ManifestInteractivity struct {
239239

240240
// ManifestScopes
241241
type ManifestScopes struct {
242-
Bot []string `json:"bot,omitempty" yaml:"bot,flow,omitempty"`
243-
User []string `json:"user,omitempty" yaml:"user,flow,omitempty"`
242+
Bot []string `json:"bot,omitempty" yaml:"bot,flow,omitempty"`
243+
BotOptional []string `json:"bot_optional,omitempty" yaml:"bot_optional,flow,omitempty"`
244+
User []string `json:"user,omitempty" yaml:"user,flow,omitempty"`
245+
UserOptional []string `json:"user_optional,omitempty" yaml:"user_optional,flow,omitempty"`
244246
}
245247

246248
// ManifestShortcutsItem

internal/shared/types/app_manifest_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,62 @@ func Test_AppManifest_AppSettings_IncomingWebhooks(t *testing.T) {
336336
}
337337
}
338338

339+
func Test_AppManifest_OAuthConfig_Scopes(t *testing.T) {
340+
tests := map[string]struct {
341+
oauthConfig *OAuthConfig
342+
expectedJSON string
343+
}{
344+
"undefined scopes are omitted": {
345+
oauthConfig: &OAuthConfig{},
346+
expectedJSON: `{}`,
347+
},
348+
"empty scopes are included": {
349+
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{}},
350+
expectedJSON: `{"scopes":{}}`,
351+
},
352+
"bot scopes are included": {
353+
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
354+
Bot: []string{"chat:write", "channels:read"},
355+
}},
356+
expectedJSON: `{"scopes":{"bot":["chat:write","channels:read"]}}`,
357+
},
358+
"user scopes are included": {
359+
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
360+
User: []string{"users:read"},
361+
}},
362+
expectedJSON: `{"scopes":{"user":["users:read"]}}`,
363+
},
364+
"bot optional scopes are included": {
365+
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
366+
BotOptional: []string{"channels:history"},
367+
}},
368+
expectedJSON: `{"scopes":{"bot_optional":["channels:history"]}}`,
369+
},
370+
"user optional scopes are included": {
371+
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
372+
UserOptional: []string{"users:read.email"},
373+
}},
374+
expectedJSON: `{"scopes":{"user_optional":["users:read.email"]}}`,
375+
},
376+
"all scope types are included": {
377+
oauthConfig: &OAuthConfig{Scopes: &ManifestScopes{
378+
Bot: []string{"chat:write"},
379+
BotOptional: []string{"channels:history"},
380+
User: []string{"users:read"},
381+
UserOptional: []string{"users:read.email"},
382+
}},
383+
expectedJSON: `{"scopes":{"bot":["chat:write"],"bot_optional":["channels:history"],"user":["users:read"],"user_optional":["users:read.email"]}}`,
384+
},
385+
}
386+
for name, tc := range tests {
387+
t.Run(name, func(t *testing.T) {
388+
actualJSON, err := json.Marshal(tc.oauthConfig)
389+
require.NoError(t, err)
390+
assert.Equal(t, tc.expectedJSON, string(actualJSON))
391+
})
392+
}
393+
}
394+
339395
func Test_AppManifest_AppSettings_FunctionRuntime(t *testing.T) {
340396
tests := map[string]struct {
341397
settings *AppSettings

0 commit comments

Comments
 (0)