Skip to content

Commit

Permalink
Merge pull request #44 from ing-bank/fix/update-libs
Browse files Browse the repository at this point in the history
Fix/update libs
  • Loading branch information
arempter authored Feb 14, 2020
2 parents 6e7aaa7 + 35665fa commit 6cf290f
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
language: scala

scala:
- 2.12.8
- 2.13.1

env:
global:
Expand Down
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ val rokkuStsVersion = scala.sys.env.getOrElse("ROKKU_STS_VERSION", "SNAPSHOT")

name := "rokku-sts"
version := rokkuStsVersion
scalaVersion := "2.12.8"
scalaVersion := "2.13.1"

scalacOptions := Seq(
"-unchecked",
Expand All @@ -23,18 +23,18 @@ updateOptions := updateOptions.value.withCachedResolution(cachedResoluton = true

assemblyJarName in assembly := "rokku-sts.jar"

val akkaVersion = "2.5.25"
val akkaHttpVersion = "10.1.9"
val keycloakVersion = "4.7.0.Final"
val akkaVersion = "2.6.3"
val akkaHttpVersion = "10.1.11"
val keycloakVersion = "8.0.2"
val logbackJson = "0.1.5"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"ch.megard" %% "akka-http-cors" % "0.3.1",
"ch.megard" %% "akka-http-cors" % "0.4.2",
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-xml" % akkaHttpVersion,
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
"org.keycloak" % "keycloak-core" % keycloakVersion,
Expand All @@ -45,11 +45,11 @@ libraryDependencies ++= Seq(
"ch.qos.logback.contrib" % "logback-json-classic" % logbackJson,
"ch.qos.logback.contrib" % "logback-jackson" % logbackJson,
"com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9",
"org.scalatest" %% "scalatest" % "3.0.5" % "test, it",
"org.scalatest" %% "scalatest" % "3.1.0" % "test, it",
"com.auth0" % "java-jwt" % "3.8.0",
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test,
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVersion % Test,
"com.amazonaws" % "aws-java-sdk-sts" % "1.11.467" % IntegrationTest)
"com.amazonaws" % "aws-java-sdk-sts" % "1.11.720" % IntegrationTest)


configs(IntegrationTest)
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.2.7
sbt.version = 1.3.8
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.5")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.6.1")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
10 changes: 5 additions & 5 deletions src/it/scala/com/ing/wbaa/rokku/sts/StsServiceItTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import java.time.Instant

import akka.actor.ActorSystem
import akka.http.scaladsl.model.Uri.{Authority, Host}
import akka.stream.ActorMaterializer
import com.amazonaws.services.securitytoken.AWSSecurityTokenService
import com.amazonaws.services.securitytoken.model.{AWSSecurityTokenServiceException, AssumeRoleRequest, GetSessionTokenRequest}
import com.ing.wbaa.rokku.sts.config.{HttpSettings, KeycloakSettings, MariaDBSettings, StsSettings}
import com.ing.wbaa.rokku.sts.data.{UserAssumeRole, UserName}
import com.ing.wbaa.rokku.sts.data.aws._
import com.ing.wbaa.rokku.sts.data.{UserAssumeRole, UserName}
import com.ing.wbaa.rokku.sts.helper.{KeycloackToken, OAuth2TokenRequest}
import com.ing.wbaa.rokku.sts.keycloak.KeycloakTokenVerifier
import com.ing.wbaa.rokku.sts.service.UserTokenDbService
import com.ing.wbaa.rokku.sts.service.db.MariaDb
import com.ing.wbaa.rokku.sts.service.db.dao.STSUserAndGroupDAO
import org.scalatest._
import org.scalatest.Assertion
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AsyncWordSpec

import scala.concurrent.duration.Duration
import scala.concurrent.{ExecutionContextExecutor, Future}
import scala.util.Random

class StsServiceItTest extends AsyncWordSpec with DiagrammedAssertions
class StsServiceItTest extends AsyncWordSpec with Diagrams
with AWSSTSClient with OAuth2TokenRequest {
override implicit val testSystem: ActorSystem = ActorSystem.create("test-system")
override implicit val materializer: ActorMaterializer = ActorMaterializer()(testSystem)
override implicit val exContext: ExecutionContextExecutor = testSystem.dispatcher

private val validCredentials = Map("grant_type" -> "password", "username" -> "userone", "password" -> "password", "client_id" -> "sts-rokku")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.RawHeader
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Sink
import com.ing.wbaa.rokku.sts.config.KeycloakSettings

Expand All @@ -18,7 +17,6 @@ case class KeycloackToken(access_token: String)
trait OAuth2TokenRequest {

protected implicit def testSystem: ActorSystem
protected implicit def materializer: ActorMaterializer
protected implicit def exContext: ExecutionContextExecutor

protected[this] def keycloakSettings: KeycloakSettings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.ing.wbaa.rokku.sts.keycloak

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.ing.wbaa.rokku.sts.config.KeycloakSettings
import com.ing.wbaa.rokku.sts.data.{BearerToken, UserGroup, UserName}
import com.ing.wbaa.rokku.sts.helper.{KeycloackToken, OAuth2TokenRequest}
import org.keycloak.common.VerificationException
import org.keycloak.representations.JsonWebToken
import org.scalatest.{Assertion, AsyncWordSpec, DiagrammedAssertions}
import org.scalatest.Assertion
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AsyncWordSpec

import scala.concurrent.{ExecutionContextExecutor, Future}

class KeycloakTokenVerifierTest extends AsyncWordSpec with DiagrammedAssertions with OAuth2TokenRequest with KeycloakTokenVerifier {
class KeycloakTokenVerifierTest extends AsyncWordSpec with Diagrams with OAuth2TokenRequest with KeycloakTokenVerifier {

override implicit val testSystem: ActorSystem = ActorSystem.create("test-system")
override implicit val materializer: ActorMaterializer = ActorMaterializer()(testSystem)
override implicit val exContext: ExecutionContextExecutor = testSystem.dispatcher

override val keycloakSettings: KeycloakSettings = new KeycloakSettings(testSystem.settings.config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.ing.wbaa.rokku.sts.service.db

import akka.actor.ActorSystem
import com.ing.wbaa.rokku.sts.config.{MariaDBSettings, StsSettings}
import org.scalatest.AsyncWordSpec
import org.scalatest.wordspec.AsyncWordSpec

import scala.util.{Failure, Success}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import com.ing.wbaa.rokku.sts.data.{UserAssumeRole, UserName}
import com.ing.wbaa.rokku.sts.data.aws.{AwsCredential, AwsSessionToken, AwsSessionTokenExpiration}
import com.ing.wbaa.rokku.sts.service.TokenGeneration
import com.ing.wbaa.rokku.sts.service.db.MariaDb
import org.scalatest.{Assertion, AsyncWordSpec}
import org.scalatest.Assertion
import org.scalatest.wordspec.AsyncWordSpec

import scala.concurrent.Future
import scala.util.Random
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.ing.wbaa.rokku.sts.data.{AccountStatus, NPA, UserGroup, UserName}
import com.ing.wbaa.rokku.sts.data.aws.{AwsAccessKey, AwsCredential}
import com.ing.wbaa.rokku.sts.service.TokenGeneration
import com.ing.wbaa.rokku.sts.service.db.MariaDb
import org.scalatest.AsyncWordSpec
import org.scalatest.wordspec.AsyncWordSpec

import scala.util.Random

Expand Down
5 changes: 1 addition & 4 deletions src/main/scala/com/ing/wbaa/rokku/sts/RokkuStsService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.stream.ActorMaterializer
import ch.megard.akka.http.cors.scaladsl.CorsDirectives.cors
import com.ing.wbaa.rokku.sts.api.{ STSApi, ServerApi, UserApi, AdminApi }
import com.ing.wbaa.rokku.sts.api.{ AdminApi, STSApi, ServerApi, UserApi }
import com.ing.wbaa.rokku.sts.config.HttpSettings
import com.typesafe.scalalogging.LazyLogging

Expand All @@ -24,8 +23,6 @@ trait RokkuStsService

implicit def system: ActorSystem

implicit val materializer: ActorMaterializer = ActorMaterializer()(system)

implicit val executionContext: ExecutionContext = system.dispatcher

protected[this] def httpSettings: HttpSettings
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/ing/wbaa/rokku/sts/api/AdminApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait AdminApi extends LazyLogging with Encryption {
def addNPA: Route = logRequestResult("debug") {
post {
path("npa") {
formFields(('npaAccount, 'awsAccessKey, 'awsSecretKey)) { (npaAccount, awsAccessKey, awsSecretKey) =>
formFields((Symbol("npaAccount"), Symbol("awsAccessKey"), Symbol("awsSecretKey"))) { (npaAccount, awsAccessKey, awsSecretKey) =>
authorizeToken(verifyAuthenticationToken) { keycloakUserInfo =>
if (userInAdminGroups(keycloakUserInfo.userGroups)) {
val awsCredentials = AwsCredential(AwsAccessKey(awsAccessKey), AwsSecretKey(awsSecretKey))
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/ing/wbaa/rokku/sts/api/STSApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ trait STSApi extends LazyLogging with TokenXML {
}

private val assumeRoleInputs = {
val inputList = ('RoleArn, 'RoleSessionName, "DurationSeconds".as[Int].?)
val inputList = (Symbol("RoleArn"), Symbol("RoleSessionName"), "DurationSeconds".as[Int].?)
(parameters(inputList) | formFields(inputList)).tmap(t =>
t.copy(_1 = AwsRoleArn(t._1), _3 = parseDurationSeconds(t._3))
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/ing/wbaa/rokku/sts/api/UserApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait UserApi extends JwtToken {
}

if (verifyInternalToken(bearerToken)) {
parameters(('accessKey, 'sessionToken.?)) { (accessKey, sessionToken) =>
parameters((Symbol("accessKey"), Symbol("sessionToken").?)) { (accessKey, sessionToken) =>
onSuccess(isCredentialActive(AwsAccessKey(accessKey), sessionToken.map(AwsSessionToken))) {

case Some(userInfo) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait KeycloakTokenVerifier extends LazyLogging {

implicit protected[this] def executionContext: ExecutionContext

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

protected[this] def verifyAuthenticationToken(token: BearerToken): Option[AuthenticationUserInfo] = Try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ExpiredTokenCleaner extends Runnable with LazyLogging {

protected[this] implicit val exContext: ExecutionContextExecutor = system.dispatcher

system.scheduler.schedule(10.seconds, 1.day, this)
system.scheduler.scheduleWithFixedDelay(10.seconds, 1.day)(this)

override def run(): Unit = {
logger.debug("start clean expired tokens")
Expand Down
8 changes: 5 additions & 3 deletions src/test/scala/com/ing/wbaa/rokku/sts/api/AdminApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest
import com.ing.wbaa.rokku.sts.config.StsSettings
import com.ing.wbaa.rokku.sts.data._
import com.ing.wbaa.rokku.sts.data.aws.AwsCredential
import org.scalatest.{ BeforeAndAfterAll, DiagrammedAssertions, WordSpec }
import org.scalatest.BeforeAndAfterAll
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AnyWordSpec

import scala.concurrent.Future

class AdminApiTest extends WordSpec
with DiagrammedAssertions
class AdminApiTest extends AnyWordSpec
with Diagrams
with ScalatestRouteTest
with BeforeAndAfterAll {

Expand Down
5 changes: 3 additions & 2 deletions src/test/scala/com/ing/wbaa/rokku/sts/api/STSApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest
import com.ing.wbaa.rokku.sts.data
import com.ing.wbaa.rokku.sts.data._
import com.ing.wbaa.rokku.sts.data.aws._
import org.scalatest.{ DiagrammedAssertions, WordSpec }
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AnyWordSpec

import scala.concurrent.Future
import scala.concurrent.duration._
import scala.xml.NodeSeq

class STSApiTest extends WordSpec with DiagrammedAssertions with ScalatestRouteTest {
class STSApiTest extends AnyWordSpec with Diagrams with ScalatestRouteTest {

class MockStsApi extends STSApi {

Expand Down
11 changes: 7 additions & 4 deletions src/test/scala/com/ing/wbaa/rokku/sts/api/ServerApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ package com.ing.wbaa.rokku.sts.api

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest.{ BeforeAndAfterAll, DiagrammedAssertions, Matchers, WordSpec }
import org.scalatest.BeforeAndAfterAll
import org.scalatest.diagrams.Diagrams
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

import scala.concurrent.Future

class ServerApiTest extends WordSpec
class ServerApiTest extends AnyWordSpec
with Matchers
with DiagrammedAssertions
with Diagrams
with ScalatestRouteTest
with BeforeAndAfterAll {

private[this] val serverRoutes = new ServerApi {
override protected[this] def checkDbConnection(): Future[Unit] = Future.successful(Unit)
override protected[this] def checkDbConnection(): Future[Unit] = Future.successful(())
}.serverRoutes

private[this] val faultyServerRoutes = new ServerApi {
Expand Down
8 changes: 5 additions & 3 deletions src/test/scala/com/ing/wbaa/rokku/sts/api/UserApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import com.auth0.jwt.algorithms.Algorithm
import com.ing.wbaa.rokku.sts.config.StsSettings
import com.ing.wbaa.rokku.sts.data.aws.{ AwsAccessKey, AwsSecretKey, AwsSessionToken }
import com.ing.wbaa.rokku.sts.data.{ STSUserInfo, UserGroup, UserName }
import org.scalatest.{ BeforeAndAfterAll, DiagrammedAssertions, WordSpec }
import org.scalatest.BeforeAndAfterAll
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AnyWordSpec

import scala.concurrent.Future

class UserApiTest extends WordSpec
with DiagrammedAssertions
class UserApiTest extends AnyWordSpec
with Diagrams
with ScalatestRouteTest
with BeforeAndAfterAll {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.ing.wbaa.rokku.sts.data.aws

import com.ing.wbaa.rokku.sts.data._
import org.scalatest.WordSpec
import org.scalatest.wordspec.AnyWordSpec

class AwsRoleArnTest extends WordSpec {
class AwsRoleArnTest extends AnyWordSpec {

"AwsRoleArn" should {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package com.ing.wbaa.rokku.sts.service
import akka.actor.ActorSystem
import com.ing.wbaa.rokku.sts.config.StsSettings
import com.ing.wbaa.rokku.sts.service.db.security.Encryption
import org.scalatest.{ DiagrammedAssertions, WordSpec }
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AnyWordSpec

class EncryptionTest extends WordSpec with DiagrammedAssertions with Encryption {
class EncryptionTest extends AnyWordSpec with Diagrams with Encryption {

val testSystem: ActorSystem = ActorSystem.create("test-system")
override protected[this] def stsSettings: StsSettings = new StsSettings(testSystem.settings.config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import java.util.concurrent.TimeUnit
import akka.actor.ActorSystem
import com.ing.wbaa.rokku.sts.config.StsSettings
import com.ing.wbaa.rokku.sts.data.aws.AwsSessionTokenExpiration
import org.scalatest.{ DiagrammedAssertions, WordSpec }
import org.scalatest.diagrams.Diagrams
import org.scalatest.wordspec.AnyWordSpec

import scala.concurrent.duration.Duration

class TokenGenerationTest extends WordSpec with DiagrammedAssertions with TokenGeneration {
class TokenGenerationTest extends AnyWordSpec with Diagrams with TokenGeneration {

val testSystem: ActorSystem = ActorSystem.create("test-system")
override protected[this] def stsSettings: StsSettings = new StsSettings(testSystem.settings.config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import java.util.concurrent.TimeUnit

import akka.actor.ActorSystem
import com.ing.wbaa.rokku.sts.config.StsSettings
import com.ing.wbaa.rokku.sts.data.{ AccountStatus, NPA, UserAssumeRole, UserGroup, UserName }
import com.ing.wbaa.rokku.sts.data.aws._
import org.scalatest.{ AsyncWordSpec, DiagrammedAssertions }
import com.ing.wbaa.rokku.sts.data._
import org.scalatest.wordspec.AsyncWordSpec
import org.scalatest.diagrams.Diagrams

import scala.concurrent.duration.Duration
import scala.concurrent.{ ExecutionContext, Future }
import scala.util.Random

class UserTokenDbServiceTest extends AsyncWordSpec with DiagrammedAssertions {
class UserTokenDbServiceTest extends AsyncWordSpec with Diagrams {

trait UserTokenDbServiceTest extends UserTokenDbService {
val testSystem: ActorSystem = ActorSystem.create("test-system")
Expand Down

0 comments on commit 6cf290f

Please sign in to comment.