Skip to content

Commit

Permalink
Use AwsSessionCredentials to support aws oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
r-tomassetti committed Oct 29, 2024
1 parent 000577c commit ad85e0b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import cats.syntax.all._
import com.commercetools.queue.QueueClient
import com.commercetools.queue.aws.sqs.SQSClient
import com.commercetools.queue.testkit.QueueClientSuite
import software.amazon.awssdk.auth.credentials.{AnonymousCredentialsProvider, AwsBasicCredentials, StaticCredentialsProvider}
import software.amazon.awssdk.auth.credentials.{AnonymousCredentialsProvider, AwsSessionCredentials, StaticCredentialsProvider}
import software.amazon.awssdk.regions.Region

import java.net.URI
Expand All @@ -40,9 +40,12 @@ class SqsClientSuite extends QueueClientSuite {
.asScala
.find(_.id == awsRegion)
.liftTo[IO](new IllegalArgumentException(s"Cannot find any suitable AWS region from $awsRegion value!"))
credentials <- (string("AWS_SQS_ACCESS_KEY"), string("AWS_SQS_ACCESS_SECRET")).mapN((accessKey, accessSecret) =>
accessKey <- string("AWS_SQS_ACCESS_KEY")
accessSecret <- string("AWS_SQS_ACCESS_SECRET")
sessionToken <- string("AWS_SQS_SESSION_TOKEN")
credentials <- IO.pure(
StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, accessSecret)
AwsSessionCredentials.create(accessKey, accessSecret, sessionToken)
))
} yield (region, credentials, None)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class QueueClientSuite
val messagesStatsSupported: Boolean = true
val inFlightMessagesStatsSupported: Boolean = true
val delayedMessagesStatsSupported: Boolean = true
val waitingTime: FiniteDuration = 10.seconds
val waitingTime: FiniteDuration = 20.seconds

final val originalMessageTTL: FiniteDuration = 10.minutes
final val originalLockTTL: FiniteDuration = 2.minutes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ trait QueueSubscriberSuite extends CatsEffectSuite { self: QueueClientSuite =>
.through(client.publish(queueName).sink(batchSize = totalMessages))
.compile
.drain
_ <- IO.sleep(3.seconds)
msgBatch <- puller.pullMessageBatch(totalMessages, waitingTime)
_ = assertEquals(msgBatch.messages.size, totalMessages)
_ <- msgBatch.nackAll
_ <- IO.sleep(3.seconds)
msgBatchNack <- puller.pullMessageBatch(totalMessages, waitingTime)
_ = assertEquals(msgBatchNack.messages.size, totalMessages)
_ <- msgBatchNack.ackAll
Expand Down

0 comments on commit ad85e0b

Please sign in to comment.