@@ -12,7 +12,12 @@ describe('DiscordStrategy', () => {
12
12
clientID : 'test-client-id' ,
13
13
clientSecret : 'test-client-secret' ,
14
14
callbackUrl : 'http://localhost:3000/callback' ,
15
- scope : [ DiscordPermissionScope . Email , DiscordPermissionScope . Identify ] ,
15
+ scope : [
16
+ DiscordPermissionScope . Email ,
17
+ DiscordPermissionScope . Identify ,
18
+ DiscordPermissionScope . Connections ,
19
+ // DiscordPermissionScope.Bot, // Not allowed scope
20
+ ] ,
16
21
prompt : 'consent' ,
17
22
} ;
18
23
@@ -114,13 +119,25 @@ describe('DiscordStrategy', () => {
114
119
strategy [ 'makeApiRequest' ] = mockMakeApiRequest ;
115
120
116
121
const result = await strategy [ 'fetchScopeData' ] (
117
- 'connections' ,
122
+ DiscordPermissionScope . Connections ,
118
123
'test-access-token' ,
119
124
) ;
120
125
121
126
expect ( result ) . toEqual ( [ { id : '123' } ] ) ;
122
127
} ) ;
123
128
129
+ it ( 'should no fetch out of scope data' , async ( ) => {
130
+ const mockMakeApiRequest = jest . fn ( ) . mockResolvedValue ( [ { id : '123' } ] ) ;
131
+ strategy [ 'makeApiRequest' ] = mockMakeApiRequest ;
132
+
133
+ const result = await strategy [ 'fetchScopeData' ] (
134
+ DiscordPermissionScope . Bot ,
135
+ 'test-access-token' ,
136
+ ) ;
137
+
138
+ expect ( result ) . toEqual ( null ) ;
139
+ } ) ;
140
+
124
141
it ( 'should enrich profile with scopes' , async ( ) => {
125
142
const profile = {
126
143
id : '123' ,
0 commit comments