-
Notifications
You must be signed in to change notification settings - Fork 31
Throw if using secret key #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,6 +319,34 @@ - (void)test_Radar_initialize { | |
| XCTAssertEqualObjects(kPublishableKey, [RadarSettings publishableKey]); | ||
| } | ||
|
|
||
| - (void)test_Radar_initialize_throwsExceptionForSecretKey { | ||
| NSString *secretKey = @"prj_test_sk_0000000000000000000000000000000000000000"; | ||
|
|
||
| XCTAssertThrows([Radar initializeWithPublishableKey:secretKey options:nil], | ||
| @"Should throw exception when secret key is used"); | ||
| } | ||
|
|
||
| - (void)test_Radar_initialize_throwsCorrectExceptionTypeForSecretKey { | ||
| NSString *secretKey = @"prj_test_sk_0000000000000000000000000000000000000000"; | ||
lmeier marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this test would cover I think it would cover all cases with just this test that verify it throws and throws the right error. But it's probably fine to have more tests. |
||
|
|
||
| @try { | ||
| [Radar initializeWithPublishableKey:secretKey options:nil]; | ||
| XCTFail(@"Expected NSInvalidArgumentException to be thrown"); | ||
| } @catch (NSException *exception) { | ||
| XCTAssertEqualObjects(exception.name, NSInvalidArgumentException, | ||
| @"Exception should be NSInvalidArgumentException"); | ||
| XCTAssertTrue([exception.reason containsString:@"Secret keys are not allowed"], | ||
| @"Exception reason should mention secret keys are not allowed"); | ||
| } | ||
| } | ||
|
|
||
| - (void)test_Radar_initialize_acceptsValidPublishableKey { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this case is covered by |
||
| NSString *validKey = @"prj_test_pk_0000000000000000000000000000000000000000"; | ||
|
|
||
| XCTAssertNoThrow([Radar initializeWithPublishableKey:validKey options:nil], | ||
| @"Should not throw exception for valid publishable key"); | ||
| } | ||
|
|
||
| - (void)test_Radar_setUserId { | ||
| NSString *userId = @"userId"; | ||
| [Radar setUserId:userId]; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.