diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/Rql2CompilerTestContext.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/Rql2CompilerTestContext.scala index c95e4b32c..1c2b85132 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/Rql2CompilerTestContext.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/Rql2CompilerTestContext.scala @@ -29,6 +29,88 @@ import java.nio.file.{Files, Path, StandardOpenOption} import scala.collection.mutable import scala.io.Source +object TestCredentials { + + ///////////////////////////////////////////////////////////////////////////// + // Dropbox Credentials + ///////////////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////////////////// + // S3 Credentials + ///////////////////////////////////////////////////////////////////////////// + + val accessKeyId = sys.env("RAW_AWS_ACCESS_KEY_ID") + val secretKeyId = sys.env("RAW_AWS_SECRET_ACCESS_KEY") + + // Bucket with public access + val UnitTestPublicBucket = "rawlabs-public-test-data" + val UnitTestPublicBucketCred = S3Credential(None, None, Some("eu-west-1")) + + // IAM user 'unit-test-private-bucket', which only has permissions only to access bucket 'rawlabs-private-test-data' + val UnitTestPrivateBucket = "rawlabs-private-test-data" + val UnitTestPrivateBucketCred = S3Credential(Some(accessKeyId), Some(secretKeyId), Some("eu-west-1")) + + val UnitTestPrivateBucket2 = "rawlabs-unit-tests" + val UnitTestPrivateBucket2Cred = S3Credential(Some(accessKeyId), Some(secretKeyId), Some("eu-west-1")) + + val UnitTestEmptyBucketPrivateBucket = "rawlabs-unit-test-empty-bucket" + val UnitTestEmptyBucketPrivateBucketCred = S3Credential(Some(accessKeyId), Some(secretKeyId), Some("eu-west-1")) + + val UnitTestListRootPrivateBucket = "rawlabs-unit-test-list-root" + val UnitTestListRootPrivateBucketCred = S3Credential(Some(accessKeyId), Some(secretKeyId), Some("eu-west-1")) + + val unitTestPrivateBucketUsEast1 = "rawlabs-unit-tests-us-east-1" + val unitTestPrivateBucketUsEast1Cred = S3Credential(Some(accessKeyId), Some(secretKeyId), Some("us-east-1")) + + /////////////////////////////////////////////////////////////////////////// + // Jdbc Credentials + /////////////////////////////////////////////////////////////////////////// + + val mysqlTestHost = sys.env("RAW_MYSQL_TEST_HOST") + val mysqlTestDB = sys.env("RAW_MYSQL_TEST_DB") + val mysqlTestUser = sys.env("RAW_MYSQL_TEST_USER") + val mysqlTestPassword = sys.env("RAW_MYSQL_TEST_PASSWORD") + val mysqlCreds = MySqlJdbcLocation(mysqlTestHost, 3306, mysqlTestDB, mysqlTestUser, mysqlTestPassword) + val pgsqlTestHost = sys.env("RAW_PGSQL_TEST_HOST") + val pgsqlTestDB = sys.env("RAW_PGSQL_TEST_DB") + val pgsqlTestUser = sys.env("RAW_PGSQL_TEST_USER") + val pgsqlTestPassword = sys.env("RAW_PGSQL_TEST_PASSWORD") + val pgsqlCreds = PostgresJdbcLocation(pgsqlTestHost, 5432, pgsqlTestDB, pgsqlTestUser, pgsqlTestPassword) + val oracleTestHost = sys.env("RAW_ORACLE_TEST_HOST") + val oracleTestDB = sys.env("RAW_ORACLE_TEST_DB") + val oracleTestUser = sys.env("RAW_ORACLE_TEST_USER") + val oracleTestPassword = sys.env("RAW_ORACLE_TEST_PASSWORD") + val oracleCreds = OracleJdbcLocation(oracleTestHost, 1521, oracleTestDB, oracleTestUser, oracleTestPassword) + val sqlServerTestHost = sys.env("RAW_SQLSERVER_TEST_HOST") + val sqlserverTestDB = sys.env("RAW_SQLSERVER_TEST_DB") + val sqlServerTestUser = sys.env("RAW_SQLSERVER_TEST_USER") + val sqlServerTestPassword = sys.env("RAW_SQLSERVER_TEST_PASSWORD") + val sqlServerCreds = SqlServerJdbcLocation( + sqlServerTestHost, + 1433, + sqlserverTestDB, + sqlServerTestUser, + sqlServerTestPassword + ) + val teradataTestHost = sys.env("RAW_TERADATA_TEST_HOST") + val teradataTestUser = sys.env("RAW_TERADATA_TEST_USER") + val teradataTestPassword = sys.env("RAW_TERADATA_TEST_PASSWORD") + val teradataCreds = TeraDataJdbcLocation(teradataTestHost, 1025, teradataTestUser, teradataTestPassword) + val snowflakeTestHost = sys.env("RAW_SNOWFLAKE_TEST_HOST") + val snowflakeTestDB = sys.env("RAW_SNOWFLAKE_TEST_DB") + val snowflakeTestUser = sys.env("RAW_SNOWFLAKE_TEST_USER") + val snowflakeTestPassword = sys.env("RAW_SNOWFLAKE_TEST_PASSWORD") + val snowflakeCreds = SnowflakeJdbcLocation( + snowflakeTestHost, + snowflakeTestDB, + snowflakeTestUser, + snowflakeTestPassword, + Map("timezone" -> "UTC") + ) + val badMysqlCreds = MySqlJdbcLocation("does-not-exist.raw-labs.com", 3306, "rdbmstest", "t0or", "$up3r$3cr3tValu3") + +} + trait Rql2CompilerTestContext extends RawTestSuite with Matchers @@ -40,6 +122,14 @@ trait Rql2CompilerTestContext // Simple inferrer with LocalInferrerTestContext { + private val secrets = new mutable.HashMap[String, String]() + + private val s3Credentials = new mutable.HashMap[String, S3Credential]() + + private val rdbmsServers = new mutable.HashMap[String, JdbcLocation]() + + protected val programOptions = new mutable.HashMap[String, String]() + def authorizedUser: InteractiveUser = InteractiveUser(Uid("janeUid"), "Jane Smith", "jane@example.com") def runnerScopes: Set[String] = Set.empty @@ -48,7 +138,17 @@ trait Rql2CompilerTestContext def maybeTraceId: Option[String] = None - protected val programOptions = new mutable.HashMap[String, String]() + def secret(name: String, value: String): Unit = { + secrets.put(name, value) + } + + def s3Bucket(name: String, bucket: S3Credential): Unit = { + s3Credentials.put(name, bucket) + } + + def rdbms(name: String, db: JdbcLocation): Unit = { + rdbmsServers.put(name, db) + } def option(key: String, value: String): Unit = { programOptions.put(key, value) @@ -468,18 +568,21 @@ trait Rql2CompilerTestContext maybeArguments: Option[Array[(String, RawValue)]] = None, scopes: Set[String] = Set.empty, options: Map[String, String] = Map.empty - ): ProgramEnvironment = ProgramEnvironment( - authorizedUser, - maybeArguments, - this.runnerScopes ++ scopes, - Map.empty, // secrets - Map.empty, // Jdbc servers - Map.empty, // http headers - Map.empty, // s3 credentials - this.options ++ options ++ programOptions, - None, // jdbcUrl - maybeTraceId - ) + ): ProgramEnvironment = { + val user = authorizedUser + ProgramEnvironment( + user, + maybeArguments, + this.runnerScopes ++ scopes, + secrets.toMap, + rdbmsServers.toMap, + Map.empty, // http headers + s3Credentials.toMap, + this.options ++ options ++ programOptions, + None, // jdbcUrl + maybeTraceId + ) + } def parseQuery(code: String): BaseProgram = tryToParse(code) match { case Right(p) => p diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/AwsPackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/AwsPackageTest.scala index ee36f6f38..f376b6f7c 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/AwsPackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/AwsPackageTest.scala @@ -13,15 +13,14 @@ package raw.compiler.rql2.tests.builtin.credentials import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -trait AwsPackageTest extends Rql2CompilerTestContext with CredentialsTestContext { +trait AwsPackageTest extends Rql2CompilerTestContext { val accessKeyId = sys.env("RAW_AWS_ACCESS_KEY_ID") val secretAccessKey = sys.env("RAW_AWS_SECRET_ACCESS_KEY") - secret(authorizedUser, "aws-secret-key", secretAccessKey) - secret(authorizedUser, "aws-access-key", accessKeyId) + secret("aws-secret-key", secretAccessKey) + secret("aws-access-key", accessKeyId) def xmlImplemented: Boolean diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/EnvironmentPackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/EnvironmentPackageTest.scala index e21b0841b..7b2f1fb04 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/EnvironmentPackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/EnvironmentPackageTest.scala @@ -13,11 +13,10 @@ package raw.compiler.rql2.tests.builtin.credentials import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -trait EnvironmentPackageTest extends Rql2CompilerTestContext with CredentialsTestContext { +trait EnvironmentPackageTest extends Rql2CompilerTestContext { - secret(authorizedUser, "my-secret", "my-secret-value") + secret("my-secret", "my-secret-value") test("""Environment.Secret("my-secret")""")(it => it should evaluateTo(""" "my-secret-value" """)) diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/LocationPackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/LocationPackageTest.scala index 4945204bc..c2e2077fc 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/LocationPackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/LocationPackageTest.scala @@ -12,19 +12,16 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.creds.dropbox.DropboxTestCreds -import raw.creds.s3.S3TestCreds import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -trait LocationPackageTest - extends Rql2CompilerTestContext - with CredentialsTestContext - with DropboxTestCreds - with S3TestCreds { +trait LocationPackageTest extends Rql2CompilerTestContext { + + import raw.compiler.rql2.tests.TestCredentials._ oauth(authorizedUser, "dropbox-refresh-token", dropboxRefreshTokenCredential) + s3Bucket(UnitTestPrivateBucket2, UnitTestPrivateBucket2Cred) + property("raw.sources.dropbox.clientId", dropboxClientId) test(""" @@ -37,12 +34,12 @@ trait LocationPackageTest // reading a public s3 bucket without registering or passing credentials test(s"""let - | data = Csv.InferAndRead("s3://${UnitTestPublicBucket.name}/students.csv") + | data = Csv.InferAndRead("s3://$UnitTestPublicBucket/students.csv") |in | Collection.Count(data) |""".stripMargin)(it => it should evaluateTo("7")) - test(s"""Location.Ls("s3://${UnitTestPublicBucket.name}/publications/")""") { it => + test(s"""Location.Ls("s3://$UnitTestPublicBucket/publications/")""") { it => it should evaluateTo("""Collection.Build( | "s3://rawlabs-public-test-data/publications/authors.parquet", | "s3://rawlabs-public-test-data/publications/authors.hjson", @@ -60,7 +57,7 @@ trait LocationPackageTest |""".stripMargin) } - test(s"""Location.Ll("s3://${UnitTestPublicBucket.name}/publications/authors.hjson") + test(s"""Location.Ll("s3://$UnitTestPublicBucket/publications/authors.hjson") |""".stripMargin) { it => it should evaluateTo("""Collection.Build( | Record.Build( @@ -78,7 +75,7 @@ trait LocationPackageTest // Cannot count lists test(s""" |let - | data = Location.Ll("s3://${UnitTestPublicBucket.name}/publications") + | data = Location.Ll("s3://$UnitTestPublicBucket/publications") |in | List.Count(data) |""".stripMargin)(it => it should evaluateTo("""12L""".stripMargin)) @@ -87,20 +84,18 @@ trait LocationPackageTest test(s"""let | data = Csv.InferAndRead( | S3.Build( - | "s3://${UnitTestPrivateBucket.name}/students.csv", - | region = "${UnitTestPrivateBucket.region.get}", - | accessKey = "${UnitTestPrivateBucket.credentials.get.accessKey}", - | secretKey = "${UnitTestPrivateBucket.credentials.get.secretKey}" + | "s3://$UnitTestPrivateBucket/students.csv", + | region = "${UnitTestPrivateBucketCred.region.get}", + | accessKey = "${UnitTestPrivateBucketCred.accessKey.get}", + | secretKey = "${UnitTestPrivateBucketCred.secretKey.get}" | ) | ) |in | Collection.Count(data) |""".stripMargin)(it => it should evaluateTo("7")) - s3Bucket(authorizedUser, UnitTestPrivateBucket2) - // using a private bucket registered in the credentials server - test(s"""String.Read(S3.Build("s3://${UnitTestPrivateBucket2.name}/file1.csv")) + test(s"""String.Read(S3.Build("s3://$UnitTestPrivateBucket2/file1.csv")) |""".stripMargin)(it => it should evaluateTo(""" "foobar" """)) } diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/MySQLPackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/MySQLPackageTest.scala index d1c42c1cc..3686ec094 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/MySQLPackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/MySQLPackageTest.scala @@ -12,16 +12,16 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.jdbc.RDBMSTestCreds +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestContext with RDBMSTestCreds { +trait MySQLPackageTest extends Rql2CompilerTestContext { + + import TestCredentials._ val mysqlRegDb = "registered-db" val mysqlTable = "tbl1" - rdbms(authorizedUser, mysqlRegDb, mysqlCreds) + rdbms(mysqlRegDb, mysqlCreds) private val ttt = "\"\"\"" // Trying all types. Not all expressions type as wanted so that @@ -112,7 +112,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte test( s"""MySQL.InferAndRead("${mysqlCreds.database}", "$mysqlTable", - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "${mysqlCreds.password.get.toString}")""".stripMargin + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", password = "${mysqlCreds.password}")""".stripMargin ) { it => it should evaluateTo( """[ @@ -126,7 +126,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte test( s"""MySQL.Read("${mysqlCreds.database}", "$mysqlTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "${mysqlCreds.password.get.toString}")""".stripMargin + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", password = "${mysqlCreds.password}")""".stripMargin ) { it => it should orderEvaluateTo( """[ @@ -142,8 +142,8 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte | d = Location.Describe(Location.Build( | "mysql://${mysqlCreds.database}/$mysqlTable", | db_host = "${mysqlCreds.host}", - | db_username = "${mysqlCreds.username.get.toString}", - | db_password = "${mysqlCreds.password.get.toString}" + | db_username = "${mysqlCreds.username}", + | db_password = "${mysqlCreds.password}" | )) |in | d.columns @@ -174,7 +174,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte s"""MySQL.Read( | "${badMysqlCreds.database}", "$mysqlTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${badMysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "${mysqlCreds.password.get.toString}" + | host = "${badMysqlCreds.host}", username = "${mysqlCreds.username}", password = "${mysqlCreds.password}" |)""".stripMargin )(it => it should runErrorAs(s"""unknown host: ${badMysqlCreds.host}""".stripMargin)) @@ -184,7 +184,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte s"""MySQL.Read( | "${mysqlCreds.database}", "$mysqlTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "${mysqlCreds.password.get.toString}", port = 1234 + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", password = "${mysqlCreds.password}", port = 1234 |)""".stripMargin )(it => it should runErrorAs(s"""connect timed out: ${mysqlCreds.database}""".stripMargin)) @@ -202,7 +202,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte s"""MySQL.Read( | "${mysqlCreds.database}", "$mysqlTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "wrong!" + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", password = "wrong!" |)""".stripMargin )(it => it should runErrorAs("""authentication failed""".stripMargin)) @@ -218,7 +218,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte test( s"""MySQL.InferAndQuery("${mysqlCreds.database}", "SELECT * FROM $mysqlTable", - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "${mysqlCreds.password.get.toString}" )""".stripMargin + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", password = "${mysqlCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -244,7 +244,7 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte test( s"""MySQL.Query("${mysqlCreds.database}", "SELECT * FROM $mysqlTable", | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get.toString}", password = "${mysqlCreds.password.get.toString}" )""".stripMargin + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", password = "${mysqlCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -297,8 +297,8 @@ trait MySQLPackageTest extends Rql2CompilerTestContext with CredentialsTestConte | Collection.Count( | MySQL.Query("${mysqlCreds.database}", "SELECT * FROM " + table, | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | host = "${mysqlCreds.host}", username = "${mysqlCreds.username.get}", - | password = "${mysqlCreds.password.get}") + | host = "${mysqlCreds.host}", username = "${mysqlCreds.username}", + | password = "${mysqlCreds.password}") | ))""".stripMargin ) { it => val error = diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/OraclePackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/OraclePackageTest.scala index ed8eeb02d..09882715b 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/OraclePackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/OraclePackageTest.scala @@ -12,17 +12,17 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.jdbc.RDBMSTestCreds +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestContext with RDBMSTestCreds { +trait OraclePackageTest extends Rql2CompilerTestContext { + + import TestCredentials._ val oracleDb = "rawdb" val oracleSchema = "rawtest" val oracleTable = "tbl1" - rdbms(authorizedUser, "oracle", oracleCreds) + rdbms( "oracle", oracleCreds) test(s"""Oracle.InferAndRead("oracle", "$oracleSchema", "$oracleTable")""") { it => assume(!compilerService.language.contains("rql2-truffle")) @@ -66,7 +66,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont test( s"""Oracle.InferAndRead("$oracleDb", "$oracleSchema", "$oracleTable", - | host = "${oracleCreds.host}", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}")""".stripMargin + | host = "${oracleCreds.host}", username = "${oracleCreds.username}", password = "${oracleCreds.password}")""".stripMargin ) { it => assume(!compilerService.language.contains("rql2-truffle")) it should evaluateTo( @@ -81,7 +81,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont test( s"""Oracle.Read("$oracleDb", "$oracleSchema", "$oracleTable", | type collection(record(A: int, B: int, C: double, D: double, X: int, Y: string)), - | host = "${oracleCreds.host}", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}" )""".stripMargin + | host = "${oracleCreds.host}", username = "${oracleCreds.username}", password = "${oracleCreds.password}" )""".stripMargin ) { it => assume(!compilerService.language.contains("rql2-truffle")) it should orderEvaluateTo( @@ -98,8 +98,8 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont | d = Location.Describe(Location.Build( | "oracle://$oracleDb/$oracleSchema/$oracleTable", | db_host = "${oracleCreds.host}", - | db_username = "${oracleCreds.username.get.toString}", - | db_password = "${oracleCreds.password.get.toString}" + | db_username = "${oracleCreds.username}", + | db_password = "${oracleCreds.password}" | )) |in | d.columns @@ -131,7 +131,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont s"""Oracle.Read( | "$oracleDb", "$oracleSchema", "$oracleTable", | type collection(record(A: int, B: int, C: double, D: double, X: int, Y: string)), - | host = "oracle.localdomain", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}" + | host = "oracle.localdomain", username = "${oracleCreds.username}", password = "${oracleCreds.password}" |)""".stripMargin ) { it => assume(!compilerService.language.contains("rql2-truffle")) @@ -143,7 +143,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont s"""Oracle.Read( | "$oracleDb", "$oracleSchema", "$oracleTable", | type collection(record(A: int, B: int, C: double, D: double, X: int, Y: string)), - | host = "localhost", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}" + | host = "localhost", username = "${oracleCreds.username}", password = "${oracleCreds.password}" |)""".stripMargin ) { it => assume(!compilerService.language.contains("rql2-truffle")) @@ -156,7 +156,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont s"""Oracle.Read( | "$oracleDb", "$oracleSchema", "$oracleTable", | type collection(record(A: int, B: int, C: double, D: double, X: int, Y: string)), - | host = "test-oracle.raw-labs.com", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}", port = 1234 + | host = "test-oracle.raw-labs.com", username = "${oracleCreds.username}", password = "${oracleCreds.password}", port = 1234 |)""".stripMargin ) { it => assume(!compilerService.language.contains("rql2-truffle")) @@ -180,7 +180,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont s"""Oracle.Read( | "$oracleDb", "$oracleSchema", "$oracleTable", | type collection(record(A: int, B: int, C: double, D: double, X: int, Y: string)), - | host = "test-oracle.raw-labs.com", username = "${oracleCreds.username.get.toString}", password = "wrong!" + | host = "test-oracle.raw-labs.com", username = "${oracleCreds.username}", password = "wrong!" |)""".stripMargin ) { it => assume(!compilerService.language.contains("rql2-truffle")) @@ -199,7 +199,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont test( s"""Oracle.InferAndQuery("$oracleDb", "SELECT * FROM $oracleSchema.$oracleTable", - | host = "test-oracle.raw-labs.com", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}" )""".stripMargin + | host = "test-oracle.raw-labs.com", username = "${oracleCreds.username}", password = "${oracleCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -225,7 +225,7 @@ trait OraclePackageTest extends Rql2CompilerTestContext with CredentialsTestCont test( s"""Oracle.Query("$oracleDb", "SELECT * FROM $oracleSchema.$oracleTable", | type collection(record(A: int, B: int, C: double, D: double, X: string, Y: string)), - | host = "${oracleCreds.host}", username = "${oracleCreds.username.get.toString}", password = "${oracleCreds.password.get.toString}" )""".stripMargin + | host = "${oracleCreds.host}", username = "${oracleCreds.username}", password = "${oracleCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/PostgreSQLPackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/PostgreSQLPackageTest.scala index 8b43b90af..a25080b3d 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/PostgreSQLPackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/PostgreSQLPackageTest.scala @@ -12,16 +12,16 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.jdbc.RDBMSTestCreds +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTestContext with RDBMSTestCreds { +trait PostgreSQLPackageTest extends Rql2CompilerTestContext { + + import TestCredentials._ val pgSchema = "rdbmstest" val pgTable = "tbl1" - rdbms(authorizedUser, "pgsql", pgsqlCreds) + rdbms("pgsql", pgsqlCreds) private val ttt = "\"\"\"" // Trying all types. Not all expressions type as wanted so that @@ -112,7 +112,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest test( s"""PostgreSQL.InferAndRead("${pgsqlCreds.database}", "$pgSchema", "$pgTable", - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "${pgsqlCreds.password.get.toString}")""".stripMargin + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", password = "${pgsqlCreds.password}")""".stripMargin ) { it => it should evaluateTo( """[ @@ -126,7 +126,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest test( s"""PostgreSQL.Read("${pgsqlCreds.database}", "$pgSchema", "$pgTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "${pgsqlCreds.password.get.toString}" )""".stripMargin + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", password = "${pgsqlCreds.password}" )""".stripMargin ) { it => it should orderEvaluateTo( """[ @@ -142,8 +142,8 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest | d = Location.Describe(Location.Build( | "pgsql://${pgsqlCreds.database}/$pgSchema/$pgTable", | db_host = "${pgsqlCreds.host}", - | db_username = "${pgsqlCreds.username.get.toString}", - | db_password = "${pgsqlCreds.password.get.toString}" + | db_username = "${pgsqlCreds.username}", + | db_password = "${pgsqlCreds.password}" | )) |in | d.columns @@ -174,7 +174,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest s"""PostgreSQL.Read( | "${pgsqlCreds.database}", "$pgSchema", "$pgTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${badMysqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "${pgsqlCreds.password.get.toString}" + | host = "${badMysqlCreds.host}", username = "${pgsqlCreds.username}", password = "${pgsqlCreds.password}" |)""".stripMargin )(it => it should runErrorAs(s"""unknown host: ${badMysqlCreds.host}""".stripMargin)) @@ -184,7 +184,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest s"""PostgreSQL.Read( | "${pgsqlCreds.database}", "$pgSchema", "$pgTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "${pgsqlCreds.password.get.toString}", port = 1234 + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", password = "${pgsqlCreds.password}", port = 1234 |)""".stripMargin )(it => it should runErrorAs(s"""connect timed out: ${pgsqlCreds.host}""".stripMargin)) @@ -202,7 +202,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest s"""PostgreSQL.Read( | "${pgsqlCreds.database}", "$pgSchema", "$pgTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "wrong!" + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", password = "wrong!" |)""".stripMargin )(it => it should runErrorAs("""authentication failed""".stripMargin)) @@ -218,7 +218,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest test( s"""PostgreSQL.InferAndQuery("${pgsqlCreds.database}", "SELECT * FROM $pgSchema.$pgTable", - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "${pgsqlCreds.password.get.toString}" )""".stripMargin + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", password = "${pgsqlCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -244,7 +244,7 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest test( s"""PostgreSQL.Query("${pgsqlCreds.database}", "SELECT * FROM $pgSchema.$pgTable", | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get.toString}", password = "${pgsqlCreds.password.get.toString}" )""".stripMargin + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", password = "${pgsqlCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -261,8 +261,8 @@ trait PostgreSQLPackageTest extends Rql2CompilerTestContext with CredentialsTest | Collection.Count( | PostgreSQL.Query("${pgsqlCreds.database}", "SELECT * FROM $pgSchema." + table, | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username.get}", - | password = "${pgsqlCreds.password.get}") + | host = "${pgsqlCreds.host}", username = "${pgsqlCreds.username}", + | password = "${pgsqlCreds.password}") | ))""".stripMargin ) { it => val error = diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/S3PackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/S3PackageTest.scala index 40d17d8f2..5a027b049 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/S3PackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/S3PackageTest.scala @@ -12,40 +12,40 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.creds.s3.S3TestCreds -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait S3PackageTest extends Rql2CompilerTestContext with CredentialsTestContext with S3TestCreds { +trait S3PackageTest extends Rql2CompilerTestContext { + + import TestCredentials._ + + s3Bucket(UnitTestPrivateBucket2, UnitTestPrivateBucket2Cred) // reading a non public s3 bucket passing credentials in the location settings test(s"""let | data = Csv.InferAndRead( | S3.Build( | "s3://rawlabs-private-test-data/students.csv", - | region = "${UnitTestPrivateBucket.region.get}", - | accessKey = "${UnitTestPrivateBucket.credentials.get.accessKey}", - | secretKey = "${UnitTestPrivateBucket.credentials.get.secretKey}" + | region = "${UnitTestPrivateBucketCred.region.get}", + | accessKey = "${UnitTestPrivateBucketCred.accessKey.get}", + | secretKey = "${UnitTestPrivateBucketCred.secretKey.get}" | ) | ) |in | Collection.Count(data) |""".stripMargin)(it => it should evaluateTo("7")) - s3Bucket(authorizedUser, UnitTestPrivateBucket2) - // using a private bucket registered in the credentials server - test(s"""String.Read(S3.Build("s3://${UnitTestPrivateBucket2.name}/file1.csv")) + test(s"""String.Read(S3.Build("s3://${UnitTestPrivateBucket2}/file1.csv")) |""".stripMargin)(it => it should evaluateTo(""" "foobar" """)) // listing a s3 bucket from us-east-1 (non default region) test(s"""let | data = Location.Ls( | S3.Build( - | "s3://${unitTestPrivateBucketUsEast1.name}/csvs/01", - | region = "${unitTestPrivateBucketUsEast1.region.get}", - | accessKey = "${unitTestPrivateBucketUsEast1.credentials.get.accessKey}", - | secretKey = "${unitTestPrivateBucketUsEast1.credentials.get.secretKey}" + | "s3://${unitTestPrivateBucketUsEast1}/csvs/01", + | region = "${unitTestPrivateBucketUsEast1Cred.region.get}", + | accessKey = "${unitTestPrivateBucketUsEast1Cred.accessKey.get}", + | secretKey = "${unitTestPrivateBucketUsEast1Cred.secretKey.get}" | ) | ) |in @@ -59,9 +59,9 @@ trait S3PackageTest extends Rql2CompilerTestContext with CredentialsTestContext test(s"""let | data = Location.Ls( | S3.Build( - | "s3://${unitTestPrivateBucketUsEast1.name}/csvs/01", - | accessKey = "${unitTestPrivateBucketUsEast1.credentials.get.accessKey}", - | secretKey = "${unitTestPrivateBucketUsEast1.credentials.get.secretKey}" + | "s3://${unitTestPrivateBucketUsEast1}/csvs/01", + | accessKey = "${unitTestPrivateBucketUsEast1Cred.accessKey.get}", + | secretKey = "${unitTestPrivateBucketUsEast1Cred.secretKey.get}" | ) | ) |in diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SnowflakePackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SnowflakePackageTest.scala index d2c17a22c..c22c0159f 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SnowflakePackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SnowflakePackageTest.scala @@ -12,18 +12,18 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.jdbc.RDBMSTestCreds +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} import raw.sources.jdbc.snowflake.SnowflakeClient -trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestContext with RDBMSTestCreds { +trait SnowflakePackageTest extends Rql2CompilerTestContext { + + import TestCredentials._ val snowflakeSchema = "PUBLIC" val snowflakeMainTable = "TBL1" val snowflakeSideTable = "TBL4" - rdbms(authorizedUser, "snowflake", snowflakeCreds) + rdbms( "snowflake", snowflakeCreds) private val ttt = "\"\"\"" // Trying all types. Not all expressions type as wanted so that @@ -81,8 +81,8 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC // this will fail immediately instead of polluting tier2 tests val client = new SnowflakeClient( snowflakeCreds.database, - snowflakeCreds.username.get, - snowflakeCreds.password.get, + snowflakeCreds.username, + snowflakeCreds.password, snowflakeCreds.accountIdentifier, snowflakeCreds.parameters )(settings) @@ -230,7 +230,7 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""Snowflake.InferAndRead("${snowflakeCreds.database}", "$snowflakeSchema", "$snowflakeMainTable", - | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username.get.toString}", password = "${snowflakeCreds.password.get.toString}")""".stripMargin + | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username}", password = "${snowflakeCreds.password}")""".stripMargin ) { it => it should evaluateTo( """[ @@ -244,7 +244,7 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""Snowflake.Read("${snowflakeCreds.database}", "$snowflakeSchema", "$snowflakeMainTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username.get.toString}", password = "${snowflakeCreds.password.get.toString}" )""".stripMargin + | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username}", password = "${snowflakeCreds.password}" )""".stripMargin ) { it => it should orderEvaluateTo( """[ @@ -260,8 +260,8 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC | d = Location.Describe(Location.Build( | "snowflake://${snowflakeCreds.database}/$snowflakeSchema/$snowflakeMainTable", | db_account_id = "${snowflakeCreds.accountIdentifier}", - | db_username = "${snowflakeCreds.username.get.toString}", - | db_password = "${snowflakeCreds.password.get.toString}" + | db_username = "${snowflakeCreds.username}", + | db_password = "${snowflakeCreds.password}" | )) |in | d.columns @@ -294,7 +294,7 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC s"""Snowflake.Read( | "${snowflakeCreds.database}", "$snowflakeSchema", "$snowflakeMainTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | accountID = "does-not-exist", username = "${snowflakeCreds.username.get.toString}", password = "${snowflakeCreds.password.get.toString}" + | accountID = "does-not-exist", username = "${snowflakeCreds.username}", password = "${snowflakeCreds.password}" |)""".stripMargin ) { it => it should runErrorAs( @@ -316,7 +316,7 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC s"""Snowflake.Read( | "${snowflakeCreds.database}", "$snowflakeSchema", "$snowflakeMainTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username.get.toString}", password = "wrong!" + | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username}", password = "wrong!" |)""".stripMargin ) { it => it should runErrorAs( @@ -336,7 +336,7 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""Snowflake.InferAndQuery("${snowflakeCreds.database}", "SELECT * FROM public.$snowflakeMainTable", - | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username.get.toString}", password = "${snowflakeCreds.password.get.toString}" )""".stripMargin + | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username}", password = "${snowflakeCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -362,7 +362,7 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""Snowflake.Query("${snowflakeCreds.database}", "SELECT * FROM public.$snowflakeMainTable", | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username.get.toString}", password = "${snowflakeCreds.password.get.toString}" )""".stripMargin + | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username}", password = "${snowflakeCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -376,8 +376,8 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""Snowflake.InferAndRead("${snowflakeCreds.database}", "$snowflakeSchema", "$snowflakeSideTable", | accountID = "${snowflakeCreds.accountIdentifier}", - | username = "${snowflakeCreds.username.get.toString}", - | password = "${snowflakeCreds.password.get.toString}", + | username = "${snowflakeCreds.username}", + | password = "${snowflakeCreds.password}", | options = [{"timezone", "America/Los_Angeles"}] |)""".stripMargin ) { it => @@ -420,8 +420,8 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""Snowflake.InferAndQuery("${snowflakeCreds.database}", "SELECT * FROM $snowflakeSchema.$snowflakeSideTable", | accountID = "${snowflakeCreds.accountIdentifier}", - | username = "${snowflakeCreds.username.get.toString}", - | password = "${snowflakeCreds.password.get.toString}", + | username = "${snowflakeCreds.username}", + | password = "${snowflakeCreds.password}", | options = [{"timezone", "UTC"}] |)""".stripMargin ) { it => @@ -467,8 +467,8 @@ trait SnowflakePackageTest extends Rql2CompilerTestContext with CredentialsTestC | Collection.Count( | Snowflake.Query("${snowflakeCreds.database}", "SELECT * FROM public." + table, | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username.get}", - | password = "${snowflakeCreds.password.get}")))""".stripMargin + | accountID = "${snowflakeCreds.accountIdentifier}", username = "${snowflakeCreds.username}", + | password = "${snowflakeCreds.password}")))""".stripMargin ) { it => val error = s"""failed to read from database snowflake:${snowflakeCreds.database}: SQL compilation error:\\nObject '${snowflakeCreds.database.toUpperCase}.PUBLIC.DONT_EXIST' does not exist or not authorized.""".stripMargin diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SqlServerPackageTest.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SqlServerPackageTest.scala index 6db6ff6c7..5226a37d3 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SqlServerPackageTest.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/builtin/credentials/SqlServerPackageTest.scala @@ -12,18 +12,18 @@ package raw.compiler.rql2.tests.builtin.credentials -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.jdbc.RDBMSTestCreds +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestContext with RDBMSTestCreds { +trait SqlServerPackageTest extends Rql2CompilerTestContext { + + import TestCredentials._ val sqlServDb = "rawtest" val sqlServRegDb = "registered-db" val sqlServSchema = "rdbmstest" val sqlServTable = "tbl1" - rdbms(authorizedUser, sqlServRegDb, sqlServerCreds) + rdbms( sqlServRegDb, sqlServerCreds) private val ttt = "\"\"\"" test(s"""SQLServer.InferAndQuery("$sqlServRegDb", $ttt @@ -110,7 +110,7 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""SQLServer.InferAndRead("$sqlServDb", "$sqlServSchema", "$sqlServTable", - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get.toString}", password = "${sqlServerCreds.password.get.toString}")""".stripMargin + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", password = "${sqlServerCreds.password}")""".stripMargin ) { it => it should evaluateTo( """[ @@ -124,7 +124,7 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""SQLServer.Read("$sqlServDb", "$sqlServSchema", "$sqlServTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get.toString}", password = "${sqlServerCreds.password.get.toString}" )""".stripMargin + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", password = "${sqlServerCreds.password}" )""".stripMargin ) { it => it should orderEvaluateTo( """[ @@ -140,8 +140,8 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC | d = Location.Describe(Location.Build( | "sqlserver://$sqlServDb/$sqlServSchema/$sqlServTable", | db_host = "${sqlServerCreds.host}", - | db_username = "${sqlServerCreds.username.get.toString}", - | db_password = "${sqlServerCreds.password.get.toString}" + | db_username = "${sqlServerCreds.username}", + | db_password = "${sqlServerCreds.password}" | )) |in | d.columns @@ -170,7 +170,7 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC s"""SQLServer.Read( | "$sqlServDb", "$sqlServSchema", "$sqlServTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "does-not-exist", username = "${sqlServerCreds.username.get.toString}", password = "${sqlServerCreds.password.get.toString}" + | host = "does-not-exist", username = "${sqlServerCreds.username}", password = "${sqlServerCreds.password}" |)""".stripMargin )(it => it should runErrorAs("""error connecting to database: does-not-exist""".stripMargin)) @@ -180,7 +180,7 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC s"""SQLServer.Read( | "$sqlServDb", "$sqlServSchema", "$sqlServTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get.toString}", password = "${sqlServerCreds.password.get.toString}", port = 1234 + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", password = "${sqlServerCreds.password}", port = 1234 |)""".stripMargin )(it => it should runErrorAs(s"""connect timed out: ${sqlServerCreds.host}""".stripMargin)) @@ -198,9 +198,9 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC s"""SQLServer.Read( | "$sqlServDb", "$sqlServSchema", "$sqlServTable", | type collection(record(a: int, b: int, c: double, d: double, x: int, y: string)), - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get.toString}", password = "wrong!" + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", password = "wrong!" |)""".stripMargin - )(it => it should runErrorAs(s"""Login failed for user '${sqlServerCreds.username.get.toString}'""".stripMargin)) + )(it => it should runErrorAs(s"""Login failed for user '${sqlServerCreds.username}'""".stripMargin)) test(s"""SQLServer.InferAndQuery("$sqlServRegDb", "SELECT * FROM $sqlServSchema.$sqlServTable")""") { it => it should evaluateTo( @@ -214,7 +214,7 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""SQLServer.InferAndQuery("$sqlServDb", "SELECT * FROM $sqlServSchema.$sqlServTable", - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get.toString}", password = "${sqlServerCreds.password.get.toString}" )""".stripMargin + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", password = "${sqlServerCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -240,7 +240,7 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC test( s"""SQLServer.Query("$sqlServDb", "SELECT * FROM $sqlServSchema.$sqlServTable", | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get.toString}", password = "${sqlServerCreds.password.get.toString}" )""".stripMargin + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", password = "${sqlServerCreds.password}" )""".stripMargin ) { it => it should evaluateTo( """[ @@ -257,8 +257,8 @@ trait SqlServerPackageTest extends Rql2CompilerTestContext with CredentialsTestC | Collection.Count( | SQLServer.Query("$sqlServDb", "SELECT * FROM $sqlServSchema." + table, | type collection(record(a: int, b: int, c: double, d: double, x: string, y: string)), - | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username.get}", - | password = "${sqlServerCreds.password.get}") + | host = "${sqlServerCreds.host}", username = "${sqlServerCreds.username}", + | password = "${sqlServerCreds.password}") | ))""".stripMargin ) { it => val error = diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD3084Test.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD3084Test.scala index f4b70bffb..c8cfb7c3d 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD3084Test.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD3084Test.scala @@ -12,16 +12,14 @@ package raw.compiler.rql2.tests.regressions.credentials -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.jdbc.RDBMSTestCreds +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait RD3084Test extends Rql2CompilerTestContext with CredentialsTestContext with RDBMSTestCreds { +trait RD3084Test extends Rql2CompilerTestContext { - rdbms(authorizedUser, "mysql-test", mysqlCreds) - rdbms(authorizedUser, "postgres-test", pgsqlCreds) - rdbms(authorizedUser, "oracle-test", oracleCreds) - rdbms(authorizedUser, "mssql-test", sqlServerCreds) + rdbms("mysql-test", TestCredentials.mysqlCreds) + rdbms("postgres-test", TestCredentials.pgsqlCreds) + rdbms("oracle-test", TestCredentials.oracleCreds) + rdbms("mssql-test", TestCredentials.sqlServerCreds) test("""MySQL.InferAndQuery("mysql-test", "select * from test_types")""") { _ should run diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD4445Test.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD4445Test.scala index f2965ed45..22efa266c 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD4445Test.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD4445Test.scala @@ -13,10 +13,8 @@ package raw.compiler.rql2.tests.regressions.credentials import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.dropbox.DropboxTestCreds -trait RD4445Test extends Rql2CompilerTestContext with CredentialsTestContext with DropboxTestCreds { +trait RD4445Test extends Rql2CompilerTestContext { dropbox(authorizedUser, dropboxToken) oauth(authorizedUser, "rawlabs-dropbox", dropboxAccessTokenCredential) diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD5932Test.scala b/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD5932Test.scala index a3f92e646..88b1c3c89 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD5932Test.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/tests/regressions/credentials/RD5932Test.scala @@ -12,13 +12,11 @@ package raw.compiler.rql2.tests.regressions.credentials -import raw.creds.s3.S3TestCreds -import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext +import raw.compiler.rql2.tests.{Rql2CompilerTestContext, TestCredentials} -trait RD5932Test extends Rql2CompilerTestContext with CredentialsTestContext with S3TestCreds { +trait RD5932Test extends Rql2CompilerTestContext { - s3Bucket(authorizedUser, UnitTestPrivateBucket) + s3Bucket(TestCredentials.UnitTestPrivateBucket, TestCredentials.UnitTestPrivateBucketCred) test("""Json.InferAndRead("s3://rawlabs-private-test-data/rd-5932.json")""") { _ should run diff --git a/snapi-client/src/test/scala/raw/compiler/rql2/truffle/TruffleWithLocalCredentialsTestContext.scala b/snapi-client/src/test/scala/raw/compiler/rql2/truffle/TruffleWithLocalCredentialsTestContext.scala index c434ee979..0e1357fd4 100644 --- a/snapi-client/src/test/scala/raw/compiler/rql2/truffle/TruffleWithLocalCredentialsTestContext.scala +++ b/snapi-client/src/test/scala/raw/compiler/rql2/truffle/TruffleWithLocalCredentialsTestContext.scala @@ -13,11 +13,6 @@ package raw.compiler.rql2.truffle import raw.compiler.rql2.tests.Rql2CompilerTestContext -import raw.creds.api.CredentialsTestContext -import raw.creds.local.LocalCredentialsTestContext -trait TruffleWithLocalCredentialsTestContext - extends Rql2CompilerTestContext - with LocalCredentialsTestContext - with CredentialsTestContext - with Rql2TruffleCompilerServiceTestContext +// FIXME (msb): Rename this to TruffleTestContext +trait TruffleWithLocalCredentialsTestContext extends Rql2CompilerTestContext with Rql2TruffleCompilerServiceTestContext diff --git a/snapi-frontend/src/test/scala/raw/inferrer/local/json/JsonOrTypeTest.scala b/snapi-frontend/src/test/scala/raw/inferrer/local/json/JsonOrTypeTest.scala index c53a93407..59e78fdec 100644 --- a/snapi-frontend/src/test/scala/raw/inferrer/local/json/JsonOrTypeTest.scala +++ b/snapi-frontend/src/test/scala/raw/inferrer/local/json/JsonOrTypeTest.scala @@ -14,18 +14,13 @@ package raw.inferrer.local.json import org.scalatest.matchers.should.Matchers.convertToAnyShouldWrapper import org.scalatest.matchers.{MatchResult, Matcher} -import raw.creds.api.CredentialsTestContext import raw.inferrer.api._ import raw.inferrer.local.LocalInferrerTestContext import raw.utils._ import java.io.StringReader -class JsonOrTypeTest - extends RawTestSuite - with SettingsTestContext - with LocalInferrerTestContext - with CredentialsTestContext { +class JsonOrTypeTest extends RawTestSuite with SettingsTestContext with LocalInferrerTestContext { private var inferrer: JsonInferrer = _