@@ -2,6 +2,10 @@ import { rest } from 'msw'
2
2
3
3
export const handlers = [
4
4
rest . get ( 'https://api.spotify.com/v1/me' , ( req , res , ctx ) => {
5
+ if ( req . headers . get ( "Authorization" ) !== "Bearer TEST_ACCESS_TOKEN" ) {
6
+ return res ( ctx . status ( 401 ) , ctx . json ( { message : 'Not authorized' } ) )
7
+ }
8
+
5
9
return res ( ctx . json (
6
10
{
7
11
"display_name" : "watsonbox" ,
@@ -22,6 +26,10 @@ export const handlers = [
22
26
} ) ,
23
27
24
28
rest . get ( 'https://api.spotify.com/v1/users/watsonbox/tracks' , ( req , res , ctx ) => {
29
+ if ( req . headers . get ( "Authorization" ) !== "Bearer TEST_ACCESS_TOKEN" ) {
30
+ return res ( ctx . status ( 401 ) , ctx . json ( { message : 'Not authorized' } ) )
31
+ }
32
+
25
33
return res ( ctx . json (
26
34
{
27
35
"href" : "https://api.spotify.com/v1/me/tracks?offset=0&limit=20" ,
@@ -108,6 +116,10 @@ export const handlers = [
108
116
109
117
// FIXME: Duplication of data
110
118
rest . get ( 'https://api.spotify.com/v1/me/tracks' , ( req , res , ctx ) => {
119
+ if ( req . headers . get ( "Authorization" ) !== "Bearer TEST_ACCESS_TOKEN" ) {
120
+ return res ( ctx . status ( 401 ) , ctx . json ( { message : 'Not authorized' } ) )
121
+ }
122
+
111
123
return res ( ctx . json (
112
124
{
113
125
"href" : "https://api.spotify.com/v1/me/tracks?offset=0&limit=20" ,
@@ -193,6 +205,10 @@ export const handlers = [
193
205
} ) ,
194
206
195
207
rest . get ( 'https://api.spotify.com/v1/users/watsonbox/playlists' , ( req , res , ctx ) => {
208
+ if ( req . headers . get ( "Authorization" ) !== "Bearer TEST_ACCESS_TOKEN" ) {
209
+ return res ( ctx . status ( 401 ) , ctx . json ( { message : 'Not authorized' } ) )
210
+ }
211
+
196
212
return res ( ctx . json (
197
213
{
198
214
"href" : "https://api.spotify.com/v1/users/watsonbox/playlists?offset=0&limit=20" ,
@@ -240,6 +256,10 @@ export const handlers = [
240
256
} ) ,
241
257
242
258
rest . get ( 'https://api.spotify.com/v1/playlists/4XOGDpHMrVoH33uJEwHWU5/tracks?offset=0&limit=10' , ( req , res , ctx ) => {
259
+ if ( req . headers . get ( "Authorization" ) !== "Bearer TEST_ACCESS_TOKEN" ) {
260
+ return res ( ctx . status ( 401 ) , ctx . json ( { message : 'Not authorized' } ) )
261
+ }
262
+
243
263
return res ( ctx . json (
244
264
{
245
265
"href" : "https://api.spotify.com/v1/playlists/4XOGDpHMrVoH33uJEwHWU5/tracks?offset=0&limit=100" ,
@@ -430,6 +450,10 @@ export const handlers = [
430
450
431
451
export const nullTrackHandlers = [
432
452
rest . get ( 'https://api.spotify.com/v1/playlists/4XOGDpHMrVoH33uJEwHWU5/tracks?offset=0&limit=10' , ( req , res , ctx ) => {
453
+ if ( req . headers . get ( "Authorization" ) !== "Bearer TEST_ACCESS_TOKEN" ) {
454
+ return res ( ctx . status ( 401 ) , ctx . json ( { message : 'Not authorized' } ) )
455
+ }
456
+
433
457
return res ( ctx . json (
434
458
{
435
459
"href" : "https://api.spotify.com/v1/playlists/4XOGDpHMrVoH33uJEwHWU5/tracks?offset=0&limit=100" ,
0 commit comments