-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug(config): move apikey validation check after bugsnag.start
- Loading branch information
1 parent
fd2b155
commit d3ea230
Showing
3 changed files
with
42 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 10 additions & 14 deletions
24
bugsnag-android-core/src/test/java/com/bugsnag/android/ApiKeyValidationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,33 @@ | ||
package com.bugsnag.android | ||
|
||
import com.bugsnag.android.internal.isInvalidApiKey | ||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class ApiKeyValidationTest { | ||
|
||
@Test(expected = IllegalArgumentException::class) | ||
fun testNullApiKey() { | ||
Configuration.isInvalidApiKey(null) | ||
} | ||
internal class ApiKeyValidationTest { | ||
|
||
@Test(expected = IllegalArgumentException::class) | ||
fun testEmptyApiKey() { | ||
Configuration.isInvalidApiKey("") | ||
isInvalidApiKey("") | ||
} | ||
|
||
@Test | ||
fun testWrongSizeApiKey() { | ||
assertTrue(Configuration.isInvalidApiKey("abfe05f")) | ||
assertTrue(Configuration.isInvalidApiKey("5d1ec5bd39a74caa1267142706a7fb212")) | ||
assertTrue(isInvalidApiKey("abfe05f")) | ||
assertTrue(isInvalidApiKey("5d1ec5bd39a74caa1267142706a7fb212")) | ||
} | ||
|
||
@Test | ||
fun testSettingNonHexApiKey() { | ||
assertTrue(Configuration.isInvalidApiKey("5d1ec5bd3Ga74caa1267142706a7fb21")) | ||
assertTrue(Configuration.isInvalidApiKey("5d1ec5bd39a7%caa1267_42706P7fb212")) | ||
assertFalse(Configuration.isInvalidApiKey("5d1ec5bd39a74caa1267142706a7fb21")) | ||
assertTrue(isInvalidApiKey("5d1ec5bd3Ga74caa1267142706a7fb21")) | ||
assertTrue(isInvalidApiKey("5d1ec5bd39a7%caa1267_42706P7fb212")) | ||
assertFalse(isInvalidApiKey("5d1ec5bd39a74caa1267142706a7fb21")) | ||
} | ||
|
||
@Test | ||
fun setApiKey() { | ||
assertFalse(Configuration.isInvalidApiKey("5d1ec5bd39a74caa1267142706a7fb21")) | ||
assertFalse(Configuration.isInvalidApiKey("000005bd39a74caa1267142706a7fb21")) | ||
assertFalse(isInvalidApiKey("5d1ec5bd39a74caa1267142706a7fb21")) | ||
assertFalse(isInvalidApiKey("000005bd39a74caa1267142706a7fb21")) | ||
} | ||
} |