Skip to content

Commit

Permalink
Moved context to last parameter.
Browse files Browse the repository at this point in the history
This will make it easier to deprecate the parameter in the future.
  • Loading branch information
mbalfour-amzn committed Oct 31, 2024
1 parent 8fc2f8e commit ffd582c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ object AuthHelper {
* @return A LocationCredentialsProvider object.
*/
suspend fun withCognitoIdentityPool(
context: Context,
identityPoolId: String,
context: Context,
): LocationCredentialsProvider {
return withContext(Dispatchers.IO) {
val locationCredentialsProvider = LocationCredentialsProvider(
Expand All @@ -42,9 +42,9 @@ object AuthHelper {
* @return A LocationCredentialsProvider object.
*/
suspend fun withCognitoIdentityPool(
context: Context,
identityPoolId: String,
region: String,
context: Context,
): LocationCredentialsProvider {
return withContext(Dispatchers.IO) {
val locationCredentialsProvider = LocationCredentialsProvider(
Expand All @@ -64,9 +64,9 @@ object AuthHelper {
* @return A LocationCredentialsProvider object.
*/
suspend fun withCognitoIdentityPool(
context: Context,
identityPoolId: String,
region: AwsRegions,
context: Context,
): LocationCredentialsProvider {
return withContext(Dispatchers.IO) {
val locationCredentialsProvider = LocationCredentialsProvider(
Expand Down Expand Up @@ -112,9 +112,9 @@ object AuthHelper {
* @return A `LocationCredentialsProvider` object.
*/
suspend fun withCredentialsProvider(
context: Context,
credentialsProvider: CredentialsProvider,
region: String,
context: Context,
): LocationCredentialsProvider {
return withContext(Dispatchers.IO) {
val locationCredentialsProvider = LocationCredentialsProvider(
Expand All @@ -132,8 +132,7 @@ object AuthHelper {
* @param region The AWS region as a string.
* @return A LocationCredentialsProvider instance.
*/
suspend fun withApiKey( context: Context,
apiKey: String, region: String): LocationCredentialsProvider {
suspend fun withApiKey(apiKey: String, region: String, context: Context): LocationCredentialsProvider {
return withContext(Dispatchers.IO) {
val locationCredentialsProvider = LocationCredentialsProvider(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AuthHelperTest {
@Test
fun `authenticateWithCognitoIdentityPool with identityPoolId creates LocationCredentialsProvider`() {
runBlocking {
val provider = AuthHelper.withCognitoIdentityPool(context, TEST_IDENTITY_POOL_ID)
val provider = AuthHelper.withCognitoIdentityPool(TEST_IDENTITY_POOL_ID, context)
assertNotNull(provider)
}
}
Expand All @@ -68,7 +68,7 @@ class AuthHelperTest {
fun `authenticateWithCognitoIdentityPool with identityPoolId and string region creates LocationCredentialsProvider`() {
runBlocking {
val provider =
AuthHelper.withCognitoIdentityPool(context, TEST_IDENTITY_POOL_ID, "us-east-1")
AuthHelper.withCognitoIdentityPool(TEST_IDENTITY_POOL_ID, "us-east-1", context)
assertNotNull(provider)
}
}
Expand All @@ -78,9 +78,9 @@ class AuthHelperTest {
runBlocking {
val provider =
AuthHelper.withCognitoIdentityPool(
context,
TEST_IDENTITY_POOL_ID,
AwsRegions.US_EAST_1
AwsRegions.US_EAST_1,
context
)
assertNotNull(provider)
}
Expand All @@ -91,9 +91,9 @@ class AuthHelperTest {
runBlocking {
val provider =
AuthHelper.withCredentialsProvider(
context,
credentialsProvider,
"us-east-1",
context,
)
assertNotNull(provider)
}
Expand All @@ -102,7 +102,7 @@ class AuthHelperTest {
@Test
fun `authenticateWithApiKey creates LocationCredentialsProvider`() {
runBlocking {
val provider = AuthHelper.withApiKey(context, TEST_API_KEY,"us-east-1")
val provider = AuthHelper.withApiKey(TEST_API_KEY,"us-east-1", context)
assertNotNull(provider)
}
}
Expand Down

0 comments on commit ffd582c

Please sign in to comment.