Skip to content

Commit

Permalink
Merge pull request #492 from bugsnag/v6-api-key-validation
Browse files Browse the repository at this point in the history
Alter api key validation to log warning
  • Loading branch information
fractalwrench committed Mar 24, 2020
2 parents 70492ce + d6f115b commit 0c50d80
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 195 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ Bugsnag Notifiers on other platforms.
from the default convenience `init()` to ensure that `apiKey` has a value set. The `apiKey`
must now be a correctly formatted one to be accepted.

* Swift: `try BugsnagConfiguration(_ apiKey)`
* Objective C: `[[BugsnagConfiguration alloc] initWithApiKey:error:]`
* Swift: `BugsnagConfiguration(_ apiKey)`
* Objective C: `[[BugsnagConfiguration alloc] initWithApiKey:]`

[#446](https://github.com/bugsnag/bugsnag-cocoa/pull/446)
[#492](https://github.com/bugsnag/bugsnag-cocoa/pull/492)

* Support editing breadcrumbs within an Event as objects. Breadcrumbs can now be
inspected and modified from callbacks, for example:
Expand Down
6 changes: 2 additions & 4 deletions Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/**
* BugsnagConfiguration error constants
*/
extern NSString * _Nonnull const BSGConfigurationErrorDomain;
typedef NS_ENUM(NSInteger, BSGConfigurationErrorCode) {
BSGConfigurationErrorInvalidApiKey = 0
};
Expand Down Expand Up @@ -238,10 +237,9 @@ BugsnagBreadcrumbs *breadcrumbs;
/**
* The designated initializer.
*/
- (instancetype _Nullable)initWithApiKey:(NSString *_Nonnull)apiKey
error:(NSError *_Nullable *_Nullable)error
- (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
NS_DESIGNATED_INITIALIZER
NS_SWIFT_NAME(init(_:)) __attribute__((swift_error(nonnull_error)));
NS_SWIFT_NAME(init(_:));

/**
* Set the endpoints to send data to. By default we'll send error reports to
Expand Down
12 changes: 3 additions & 9 deletions Source/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
static NSString *const BSGApiKeyError = @"apiKey must be a 32-digit hexadecimal value.";
static NSString *const BSGInitError = @"Init is unavailable. Use [[BugsnagConfiguration alloc] initWithApiKey:] instead.";
static const int BSGApiKeyLength = 32;
NSString * const BSGConfigurationErrorDomain = @"com.Bugsnag.CocoaNotifier.Configuration";

// User info persistence keys
NSString * const kBugsnagUserKeychainAccount = @"BugsnagUserKeychainAccount";
Expand Down Expand Up @@ -104,15 +103,10 @@ - (instancetype)init {
/**
* The designated initializer.
*/
-(instancetype)initWithApiKey:(NSString *)apiKey
error:(NSError * _Nullable __autoreleasing * _Nullable)error
- (instancetype _Nonnull)initWithApiKey:(NSString *_Nonnull)apiKey
{
if (! [BugsnagConfiguration isValidApiKey:apiKey]) {
*error = [NSError errorWithDomain:BSGConfigurationErrorDomain
code:BSGConfigurationErrorInvalidApiKey
userInfo:@{NSLocalizedDescriptionKey : @"Invalid API key. Should be a 32-digit hex string."}];

return nil;
if (![BugsnagConfiguration isValidApiKey:apiKey]) {
bsg_log_err(@"Invalid configuration. apiKey should be a 32-character hexademical string, got \"%@\"", apiKey);
}

self = [super init];
Expand Down
3 changes: 1 addition & 2 deletions Tests/BugsnagBaseUnitTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ -(void)setUpBugsnagWillCallNotify:(bool)willNotify
-(void)setUpBugsnagWillCallNotify:(bool)willNotify
andPersistUser:(bool)willPersistUser
{
NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[configuration setPersistUser:willPersistUser];

if (willNotify) {
Expand Down
6 changes: 2 additions & 4 deletions Tests/BugsnagBreadcrumbsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ - (void)testBreadcrumbFromDict {
*/
- (void)testCallbackFreeConstructors2 {
// Prevent sending events
NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[configuration addOnSendBlock:^bool(BugsnagEvent * _Nonnull event) { return false; }];
[Bugsnag startBugsnagWithConfiguration:configuration];

Expand Down Expand Up @@ -362,8 +361,7 @@ - (void)testCallbackFreeConstructors2 {
*/
- (void)testCallbackFreeConstructors3 {
// Prevent sending events
NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[configuration addOnSendBlock:^bool(BugsnagEvent * _Nonnull event) { return false; }];
[Bugsnag startBugsnagWithConfiguration:configuration];

Expand Down
114 changes: 47 additions & 67 deletions Tests/BugsnagConfigurationTests.m

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Tests/BugsnagEventTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ @interface BugsnagEventTests : BugsnagBaseUnitTest
@implementation BugsnagEventTests

- (void)testNotifyReleaseStagesSendsFromConfig {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.notifyReleaseStages = @[ @"foo" ];
config.releaseStage = @"foo";
BugsnagHandledState *state =
Expand All @@ -43,7 +43,7 @@ - (void)testNotifyReleaseStagesSendsFromConfig {
}

- (void)testNotifyReleaseStagesSkipsSendFromConfig {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.notifyReleaseStages = @[ @"foo", @"bar" ];
config.releaseStage = @"not foo or bar";

Expand All @@ -60,7 +60,7 @@ - (void)testNotifyReleaseStagesSkipsSendFromConfig {
}

- (void)testSessionJson {
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];

BugsnagHandledState *state =
[BugsnagHandledState handledStateWithSeverityReason:HandledException];
Expand Down
6 changes: 3 additions & 3 deletions Tests/BugsnagPluginTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ @implementation BugsnagPluginTest

- (void)testAddPlugin {
id<BugsnagPlugin> plugin = [FakePlugin new];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[config addPlugin:plugin];
XCTAssertEqual([config.plugins anyObject], plugin);
}
Expand All @@ -55,7 +55,7 @@ - (void)testPluginLoaded {
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Plugin Loaded by Bugsnag"];
plugin.expectation = expectation;

BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[config addPlugin:plugin];
[Bugsnag startBugsnagWithConfiguration:config];
[self waitForExpectations:@[expectation] timeout:3.0];
Expand All @@ -67,7 +67,7 @@ - (void)testCrashyPluginDoesNotCrashApp {
CrashyPlugin *plugin = [CrashyPlugin new];
plugin.expectation = expectation;

BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[config addPlugin:plugin];
[Bugsnag startBugsnagWithConfiguration:config];
[self waitForExpectations:@[expectation] timeout:3.0];
Expand Down
2 changes: 1 addition & 1 deletion Tests/BugsnagSessionTrackerStopTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation BugsnagSessionTrackerStopTest

- (void)setUp {
[super setUp];
self.configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
self.configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
self.configuration.autoTrackSessions = NO;
self.tracker = [[BugsnagSessionTracker alloc] initWithConfig:self.configuration postRecordCallback:nil];
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/BugsnagSessionTrackerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ @implementation BugsnagSessionTrackerTest

- (void)setUp {
[super setUp];
self.configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
self.configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[self.configuration deletePersistedUserData];
self.sessionTracker = [[BugsnagSessionTracker alloc] initWithConfig:self.configuration
postRecordCallback:nil];
Expand Down
6 changes: 3 additions & 3 deletions Tests/BugsnagSinkTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)setUp {
self.rawReportData = [NSJSONSerialization JSONObjectWithData:contentData
options:0
error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.autoDetectErrors = NO;
// This value should not appear in the assertions, as it is not equal to
// the release stage in the serialized report
Expand Down Expand Up @@ -319,7 +319,7 @@ - (NSDictionary *)reportFromHandledState:(BugsnagHandledState *)state {
BugsnagEvent *report =
[[BugsnagEvent alloc] initWithErrorName:@"TestError"
errorMessage:@"Error for testing"
configuration:[[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil]
configuration:[[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1]
metadata:[NSDictionary new]
handledState:state
session:nil];
Expand Down Expand Up @@ -402,7 +402,7 @@ - (void)testCallbackSpecified {
BugsnagEvent *report =
[[BugsnagEvent alloc] initWithErrorName:@"TestError"
errorMessage:@"Error for testing"
configuration:[[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:nil]
configuration:[[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1]
metadata:[NSDictionary new]
handledState:state
session:nil];
Expand Down
18 changes: 6 additions & 12 deletions Tests/BugsnagTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ @implementation BugsnagTests
* A boilerplate helper method to setup Bugsnag
*/
-(void)setUpBugsnagWillCallNotify:(bool)willNotify {
NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
if (willNotify) {
[configuration addOnSendBlock:^bool(BugsnagEvent * _Nonnull event) { return false; }];
}
Expand Down Expand Up @@ -125,8 +124,7 @@ - (void)testGetMetadata {
* or mocking is required to isolate and test the session pausing semantics.
*/
-(void)testBugsnagPauseSession {
NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[configuration addOnSendBlock:^bool(BugsnagEvent * _Nonnull event) { return false; }];

[Bugsnag startBugsnagWithConfiguration:configuration];
Expand All @@ -142,8 +140,7 @@ - (void)testMutableContext {
// Allow for checks inside blocks that may (potentially) be run asynchronously
__block XCTestExpectation *expectation1 = [self expectationWithDescription:@"Localized metadata changes"];

NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
[configuration setContext:@"firstContext"];
[configuration addOnSendBlock:^bool(BugsnagEvent * _Nonnull event) { return false; }];

Expand Down Expand Up @@ -225,8 +222,7 @@ - (void)testRemoveOnSessionBlock {
__block XCTestExpectation *expectation2 = [self expectationWithDescription:@"Remove On Session Block 2"];
expectation2.inverted = YES;

NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];

// non-sending bugsnag
[configuration addOnSendBlock:^bool(BugsnagEvent * _Nonnull event) { return false; }];
Expand Down Expand Up @@ -262,8 +258,7 @@ - (void)testAddOnSessionBlock {
__block XCTestExpectation *expectation2 = [self expectationWithDescription:@"Remove On Session Block 3X"];
expectation2.inverted = YES;

NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
configuration.autoTrackSessions = NO;

// non-sending bugsnag
Expand Down Expand Up @@ -308,8 +303,7 @@ - (void) testOnSendBlocks {
__block int called = 0; // A counter

// Prevent sending events
NSError *error;
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error:&error];
BugsnagConfiguration *configuration = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
// We'll not be able to use the onSend -> false route to fail calls to notify()
[configuration setEndpointsForNotify:@"http://not.valid.bugsnag/not/an/endpoint"
sessions:@"http://not.valid.bugsnag/not/an/endpoint"];
Expand Down
9 changes: 3 additions & 6 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ Guide to ease migrations between significant changes

#### Instantiation

Initializing a configuration now requires a valid API key, setting an error
parameter if initialization fails. In Swift, creating a configuration is now
handled via the `try` mechanism.
Initializing a configuration requires a valid API key.

```objc
NSError *error;
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:@"YOUR API KEY HERE"
error:&error];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:@"YOUR API KEY HERE"];
```
```swift
let config = try BugsnagConfiguration("YOUR API KEY HERE")
let config = BugsnagConfiguration("YOUR API KEY HERE")
```

The exact error is available using the `BSGConfigurationErrorDomain` and
Expand Down
21 changes: 7 additions & 14 deletions features/fixtures/ios-swift-cocoapods/iOSTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

internal func prepareConfig(apiKey: String, mockAPIPath: String) -> BugsnagConfiguration {
do {
if let config = try BugsnagConfiguration(apiKey) {
// Enabling by default to check not only the OOM reporting tests but
// also that extra reports aren't erroneously sent in other conditions
// when OOM reporting is enabled
config.enabledErrorTypes.insert(.OOMs)
config.setEndpoints(notify: mockAPIPath, sessions: mockAPIPath)
return config
}
}
catch {
assert(false)
}
fatalError("Unable to create BugsnagConfiguration")
let config = BugsnagConfiguration(apiKey)
// Enabling by default to check not only the OOM reporting tests but
// also that extra reports aren't erroneously sent in other conditions
// when OOM reporting is enabled
config.enabledErrorTypes.insert(.OOMs)
config.setEndpoints(notify: mockAPIPath, sessions: mockAPIPath)
return config
}

func triggerEvent(scenario: Scenario, delay: TimeInterval, mode: String) {
Expand Down
4 changes: 0 additions & 4 deletions iOS/Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
000DF29423DB4B4900A883CE /* TestConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 000DF29323DB4B4900A883CE /* TestConstants.m */; };
000E6E9E23D8690F009D8194 /* BugsnagSwiftConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000E6E9D23D8690F009D8194 /* BugsnagSwiftConfigurationTests.swift */; };
000E6EA323D8AC8C009D8194 /* UPGRADING.md in Resources */ = {isa = PBXBuildFile; fileRef = 000E6E9F23D8AC8C009D8194 /* UPGRADING.md */; };
000E6EA423D8AC8C009D8194 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 000E6EA023D8AC8C009D8194 /* README.md */; };
Expand Down Expand Up @@ -420,7 +419,6 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
000DF29323DB4B4900A883CE /* TestConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestConstants.m; sourceTree = "<group>"; };
000E6E9B23D84DB1009D8194 /* BugsnagTestConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BugsnagTestConstants.h; path = ../../Tests/BugsnagTestConstants.h; sourceTree = "<group>"; };
000E6E9C23D8690E009D8194 /* Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Bridging-Header.h"; sourceTree = "<group>"; };
000E6E9D23D8690F009D8194 /* BugsnagSwiftConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BugsnagSwiftConfigurationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -807,7 +805,6 @@
8A2C8F951C6BC08600846019 /* report.json */,
000DF29223DB4A6B00A883CE /* Swift Tests */,
E70EE0891FD7047D00FA745C /* KSCrash */,
000DF29323DB4B4900A883CE /* TestConstants.m */,
00D7ACAC23E9C63000FBE4A7 /* BugsnagTests.m */,
00F9393723FC4F63008C7073 /* BugsnagTestsDummyClass.h */,
00F9393823FC4F64008C7073 /* BugsnagTestsDummyClass.m */,
Expand Down Expand Up @@ -1320,7 +1317,6 @@
E733A76F1FD709B7003EAA29 /* KSCrashReportStore_Tests.m in Sources */,
E70EE0781FD7039E00FA745C /* RFC3339DateTool_Tests.m in Sources */,
8A530CC422FDD51F00F0C108 /* KSCrashIdentifierTests.m in Sources */,
000DF29423DB4B4900A883CE /* TestConstants.m in Sources */,
8A4E733F1DC13281001F7CC8 /* BugsnagConfigurationTests.m in Sources */,
E784D25A1FD70C25004B01E1 /* KSJSONCodec_Tests.m in Sources */,
009131BC23F46279000810D9 /* BugsnagMetadataTests.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion iOS/BugsnagTests/BSGOutOfMemoryWatchdogTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ @implementation BSGOutOfMemoryWatchdogTests

- (void)setUp {
[super setUp];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1 error: nil];
BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithApiKey:DUMMY_APIKEY_32CHAR_1];
config.autoDetectErrors = NO;
config.codeBundleId = @"codeBundleIdHere";
config.releaseStage = @"MagicalTestingTime";
Expand Down
19 changes: 2 additions & 17 deletions iOS/BugsnagTests/Swift Tests/BugsnagSwiftConfigurationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@ class BugsnagSwiftConfigurationTests: XCTestCase {
* (read: longer) ObjC invocation).
*/
func testDesignatedInitializerHasCorrectNS_SWIFT_NAME() {

do {
let _ = try BugsnagConfiguration(DUMMY_APIKEY_16CHAR)
XCTFail("Erronoeusly initialized a BugsnagConfiguration object with an invalid apiKey")
}
catch let e as NSError {
XCTAssertEqual(e.domain, BSGConfigurationErrorDomain)
XCTAssertEqual(e.code, BSGConfigurationErrorCode.invalidApiKey.rawValue)
}

do {
let config = try BugsnagConfiguration(DUMMY_APIKEY_32CHAR_1)
XCTAssertEqual(config?.apiKey, DUMMY_APIKEY_32CHAR_1)
}
catch let e as NSError {
XCTFail("Failed to initialize a BugsnagConfiguration object with a correct apiKey: \(e.domain), \(e.code)")
}
let config = BugsnagConfiguration(DUMMY_APIKEY_16CHAR)
XCTAssertEqual(config.apiKey, DUMMY_APIKEY_16CHAR)
}
}
Loading

0 comments on commit 0c50d80

Please sign in to comment.