Skip to content

Commit 0c49549

Browse files
Fix tests
1 parent 2783bea commit 0c49549

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

samples/oauth-3rd-party/create.ipynb

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,33 +168,31 @@
168168
"from users import UserHelper\n",
169169
"from authfactory import AuthFactory\n",
170170
"\n",
171-
"tests = ApimTesting(\"OAuth 3rd Party (Spotify) Sample Tests\")\n",
171+
"tests = ApimTesting(\"OAuth 3rd Party (Spotify) Sample Tests\", sample_folder, deployment)\n",
172172
"\n",
173173
"# 1) Marketing Member Role\n",
174174
"# Create a JSON Web Token with a payload and sign it with the symmetric key from above.\n",
175175
"encoded_jwt_token_marketing_member = AuthFactory.create_symmetric_jwt_token_for_user(UserHelper.get_user_by_role(Role.MARKETING_MEMBER), nb_helper.jwt_key_value)\n",
176176
"print(f'\\nJWT token for Marketing Member:\\n{encoded_jwt_token_marketing_member}') # this value is used to call the APIs via APIM\n",
177177
"\n",
178-
"# 2) Issue a direct request to API Management\n",
179-
"artist_id = '6XpaIBNiVzIetEPCWDvAFP' # Whitney Houston's Spotify Artist ID\n",
180-
"reqsApim = ApimRequests(apim_gateway_url)\n",
181-
"reqsApim.headers['Authorization'] = f'Bearer {encoded_jwt_token_marketing_member}'\n",
182-
"\n",
183-
"output = reqsApim.singleGet(f'/oauth-3rd-party-spotify/artists/{artist_id}', msg = 'Calling the Spotify Artist API via API Management Gateway URL. Response codes 200 and 403 are both valid depending on the infrastructure used.')\n",
184-
"artist = json.loads(output)\n",
185-
"tests.verify(artist['name'], 'Whitney Houston')\n",
186-
"utils.print_info(f'{artist[\"name\"]} has a popularity rating of {artist[\"popularity\"]} with {artist[\"followers\"][\"total\"]:,} followers on Spotify.')\n",
187-
"\n",
188-
"# 2) Issue requests against Front Door.\n",
189-
"# Check if the infrastructure architecture deployment uses Azure Front Door.\n",
178+
"# Issue requests against Front Door.\n",
190179
"utils.print_message('Checking if the infrastructure architecture deployment uses Azure Front Door.', blank_above = True)\n",
191180
"afd_endpoint_url = utils.get_frontdoor_url(deployment, rg_name)\n",
192181
"\n",
193182
"if afd_endpoint_url:\n",
194-
" artist_id = '2VSHKHBTiXWplO8lxcnUC9' # Taylor Swift's Spotify Artist ID\n",
183+
" artist_id = '06HL4z0CvFAxyc27GXpf02' # Taylor Swift's Spotify Artist ID\n",
195184
" reqsAfd = ApimRequests(afd_endpoint_url)\n",
196185
" reqsAfd.headers['Authorization'] = f'Bearer {encoded_jwt_token_marketing_member}'\n",
197-
" output = reqsAfd.singleGet(f'/oauth-3rd-party-spotify/artists/{artist_id}', msg = 'Calling the Spotify Artist API via API Management Gateway URL. Response codes 200 and 403 are both valid depending on the infrastructure used.')\n",
186+
" output = reqsAfd.singleGet(f'/oauth-3rd-party-spotify/artists/{artist_id}', msg = 'Calling the Spotify Artist API via API Management Gateway URL.')\n",
187+
" artist = json.loads(output)\n",
188+
" tests.verify(artist['name'], 'Taylor Swift')\n",
189+
" utils.print_info(f'{artist[\"name\"]} has a popularity rating of {artist[\"popularity\"]} with {artist[\"followers\"][\"total\"]:,} followers on Spotify.')\n",
190+
"else:\n",
191+
" # Issue a direct request to API Management\n",
192+
" artist_id = '6XpaIBNiVzIetEPCWDvAFP' # Whitney Houston's Spotify Artist ID\n",
193+
" reqsApim = ApimRequests(apim_gateway_url)\n",
194+
" reqsApim.headers['Authorization'] = f'Bearer {encoded_jwt_token_marketing_member}'\n",
195+
" output = reqsApim.singleGet(f'/oauth-3rd-party-spotify/artists/{artist_id}', msg = 'Calling the Spotify Artist API via API Management Gateway URL.')\n",
198196
" artist = json.loads(output)\n",
199197
" tests.verify(artist['name'], 'Whitney Houston')\n",
200198
" utils.print_info(f'{artist[\"name\"]} has a popularity rating of {artist[\"popularity\"]} with {artist[\"followers\"][\"total\"]:,} followers on Spotify.')\n",

0 commit comments

Comments
 (0)