@@ -12,6 +12,7 @@ type testCase struct {
12
12
}
13
13
14
14
func runPatTest (t * testing.T , tests map [string ]testCase , matchFunc func (data string ) map [string ]struct {}) {
15
+ t .Helper ()
15
16
for name , test := range tests {
16
17
t .Run (name , func (t * testing.T ) {
17
18
matches := matchFunc (test .Input )
@@ -98,6 +99,7 @@ tenant_id = "57aabdfc-6ce0-4828-94a2-9abe277892ec"`,
98
99
"974fde14-c3a4-481b-9b03-cfce18213a07" : {},
99
100
},
100
101
},
102
+ // https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/b444dd5f8800c298016ddd9da2e6c05b0bf4b02c/tests/Microsoft.Identity.Test.Common/TestConstants.cs#L241-L245
101
103
"login.microsoftonline.com" : {
102
104
Input : ` auth: {
103
105
authority: 'https://login.microsoftonline.com/7bb339cb-e94c-4a85-884c-48ebd9bb28c3',
@@ -113,6 +115,12 @@ tenant_id = "57aabdfc-6ce0-4828-94a2-9abe277892ec"`,
113
115
"7bb339cb-e94c-4a85-884c-48ebd9bb28c3" : {},
114
116
},
115
117
},
118
+ "login.microsoft.com" : {
119
+ Input : `# SYSTEM_CONFIGURATION_ISSUER_URI=https://login.microsoft.com/2b820e29-94a2-402f-b666-c88ebcc69eb4/v2.0` ,
120
+ Expected : map [string ]struct {}{
121
+ "2b820e29-94a2-402f-b666-c88ebcc69eb4" : {},
122
+ },
123
+ },
116
124
"sts.windows.net" : {
117
125
Input : `{
118
126
"aud": "00000003-0000-0000-c000-000000000000",
@@ -263,6 +271,14 @@ $ApplicationId = "1e002bca-c6e2-446e-a29e-a221909fe8aa"`,
263
271
"902aeb6d-29c7-4f6e-849d-4b933117e320" : {},
264
272
},
265
273
},
274
+ "cleint (typo)" : {
275
+ Input : ` console.log({
276
+ cleintId:
277
+ "f3a45cb9-e388-4358-a6ef-08a63f97457c",` ,
278
+ Expected : map [string ]struct {}{
279
+ "f3a45cb9-e388-4358-a6ef-08a63f97457c" : {},
280
+ },
281
+ },
266
282
"clientid" : {
267
283
Input : `export const msalConfig = {
268
284
auth: {
@@ -306,6 +322,47 @@ subscription_id = "47ab1364-000d-4a53-838d-1537b1e3b49f"
306
322
"21e144ac-532d-49ad-ba15-1c40694ce8b1" : {},
307
323
},
308
324
},
325
+ "uri - api://" : {
326
+ Input : `AUDIENCE=api://51aaa91a-bb09-40cd-9f1f-e8c0936246c6/.default` ,
327
+ Expected : map [string ]struct {}{
328
+ "51aaa91a-bb09-40cd-9f1f-e8c0936246c6" : {},
329
+ },
330
+ },
331
+ "uri - http://" : {
332
+ Input : `AUDIENCE=http://ceb233fb-f14c-4330-9c5b-91f7db4970e1/.default` ,
333
+ Expected : map [string ]struct {}{
334
+ "ceb233fb-f14c-4330-9c5b-91f7db4970e1" : {},
335
+ },
336
+ },
337
+ "uri - https://" : {
338
+ Input : `AUDIENCE=https://47c3cfeb-b7f4-466a-b690-f7fcc79472a9/.default` ,
339
+ Expected : map [string ]struct {}{
340
+ "47c3cfeb-b7f4-466a-b690-f7fcc79472a9" : {},
341
+ },
342
+ },
343
+ "uri - myapps.microsoft.com" : {
344
+ Input : `# Linkcheck configuration
345
+ linkcheck_ignore = [
346
+ "https://myapps.microsoft.com/signin/01501f0f-c48b-4327-92a2-2324949b0a9c?tenantId=e4cbd4d7-327c-47fc-bcde-1005207021a5",
347
+ ]` ,
348
+ Expected : map [string ]struct {}{
349
+ "01501f0f-c48b-4327-92a2-2324949b0a9c" : {},
350
+ },
351
+ },
352
+ "uri - myapps.microsoft.com with name" : {
353
+ Input : `$LoginURL = 'https://myapps.microsoft.com/signin/App1/c370c8f6-0cb5-44b2-a903-c6cbd5ff6ce4?tenantId=74d7c41b-e3b6-4d40-88cf-436fd5fc231a'` ,
354
+ Expected : map [string ]struct {}{
355
+ "c370c8f6-0cb5-44b2-a903-c6cbd5ff6ce4" : {},
356
+ },
357
+ },
358
+ // TODO
359
+ // "createdBy": {
360
+ // Input: ` "systemData": {
361
+ // "createdAt": "2023-08-21T00:30:04.2907836\u002B00:00",
362
+ // "createdBy": "117311a5-df69-4fff-a301-6be98c1bd0ab",
363
+ // "createdByType": "Application"
364
+ // }`,
365
+ // },
309
366
310
367
// Arbitrary test cases
311
368
"spacing" : {
@@ -320,6 +377,21 @@ subscription_id = "47ab1364-000d-4a53-838d-1537b1e3b49f"
320
377
"f12345c6-7890-1f23-b456-789eb0bb1c23" : {},
321
378
},
322
379
},
380
+
381
+ // Invalid
382
+ "invalid uri" : {
383
+ Input : `# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif` ,
384
+ },
385
+ "invalid - AppInsights UUID" : {
386
+ Input : ` "Date": "Mon, 21 Aug 2023 00:29:56 GMT",
387
+ "Request-Context": "appId=cid-v1:2d2e8e63-272e-4b3c-8598-4ee570a0e70d",
388
+ "Strict-Transport-Security": "max-age=15724800; includeSubDomains; preload",` ,
389
+ },
390
+ "invalid - client-request-id" : {
391
+ Input : ` "Accept-Encoding": "gzip, deflate",
392
+ "client-request-id": "c9e15037-e93c-4da9-b885-9641a826ed9a",
393
+ "Connection": "keep-alive",` ,
394
+ },
323
395
}
324
396
325
397
runPatTest (t , cases , FindClientIdMatches )
0 commit comments