@@ -401,4 +401,116 @@ - (void)verifyOldGbraidDataIsCleared {
401401 XCTAssertNil ([BNCPreferenceHelper sharedInstance ].referrerGBRAIDInitDate );
402402}
403403
404+ - (void )testReferringURLWithSccid {
405+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=12345" ];
406+ NSDictionary *expected = @{
407+ @" sccid" : @" 12345"
408+ };
409+
410+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
411+ [utility parseReferringURL: url];
412+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
413+
414+ XCTAssert ([expected isEqualToDictionary: params]);
415+ }
416+
417+ - (void )testReferringURLWithSccidMixedCase {
418+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?ScCiD=12345" ];
419+ NSDictionary *expected = @{
420+ @" sccid" : @" 12345"
421+ };
422+
423+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
424+ [utility parseReferringURL: url];
425+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
426+
427+ XCTAssert ([expected isEqualToDictionary: params]);
428+ }
429+
430+ - (void )testReferringURLWithSccidNoValue {
431+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=" ];
432+ NSDictionary *expected = @{
433+ @" sccid" : @" "
434+ };
435+
436+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
437+ [utility parseReferringURL: url];
438+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
439+
440+ XCTAssert ([expected isEqualToDictionary: params]);
441+ }
442+
443+ - (void )testReferringURLWithSccidValueCasePreserved {
444+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=aAbBcC" ];
445+ NSDictionary *expected = @{
446+ @" sccid" : @" aAbBcC"
447+ };
448+
449+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
450+ [utility parseReferringURL: url];
451+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
452+
453+ XCTAssert ([expected isEqualToDictionary: params]);
454+ }
455+
456+ - (void )testReferringURLWithSccidIgnoredParam {
457+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=12345&other=abcde" ];
458+ NSDictionary *expected = @{
459+ @" sccid" : @" 12345"
460+ };
461+
462+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
463+ [utility parseReferringURL: url];
464+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
465+
466+ XCTAssert ([expected isEqualToDictionary: params]);
467+ }
468+
469+ - (void )testReferringURLWithSccidFragment {
470+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=12345#header" ];
471+ NSDictionary *expected = @{
472+ @" sccid" : @" 12345"
473+ };
474+
475+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
476+ [utility parseReferringURL: url];
477+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
478+
479+ XCTAssert ([expected isEqualToDictionary: params]);
480+ }
481+
482+ - (void )testReferringURLWithSccidAsFragment {
483+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?other=abcde#sccid=12345" ];
484+ NSDictionary *expected = @{ };
485+
486+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
487+ [utility parseReferringURL: url];
488+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
489+
490+ XCTAssert ([expected isEqualToDictionary: params]);
491+ }
492+
493+ - (void )testReferringURLWithSccidOverwritesValue {
494+ NSURL *url = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=12345" ];
495+ NSDictionary *expected = @{
496+ @" sccid" : @" 12345"
497+ };
498+
499+ NSURL *url2 = [NSURL URLWithString: @" https://bnctestbed.app.link?sccid=abcde" ];
500+ NSDictionary *expected2 = @{
501+ @" sccid" : @" abcde"
502+ };
503+
504+ BNCReferringURLUtility *utility = [self referringUtilityForTests ];
505+ [utility parseReferringURL: url];
506+ NSDictionary *params = [utility referringURLQueryParamsForEndpoint: openEndpoint];
507+ XCTAssert ([expected isEqualToDictionary: params]);
508+
509+ [utility parseReferringURL: url2];
510+ NSDictionary *params2 = [utility referringURLQueryParamsForEndpoint: openEndpoint];
511+
512+ XCTAssert ([expected2 isEqualToDictionary: params2]);
513+ }
514+
515+
404516@end
0 commit comments