Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelbranco80 committed Aug 8, 2024
1 parent 80d5b89 commit cbcfab8
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import raw.compiler.base.source.{BaseProgram, Type}
import raw.compiler.rql2.api.{Rql2CompilerServiceTestContext, Rql2OutputTestContext}
import raw.inferrer.local.LocalInferrerTestContext
import raw.protocol.{
DropboxAccessTokenConfig,
HttpHeadersConfig,
LocationConfig,
MySqlConfig,
Expand Down Expand Up @@ -237,6 +238,11 @@ trait Rql2CompilerTestContext
locationConfig(name, LocationConfig.newBuilder().setHttpHeaders(httpConfig).build())
}

def dropbox(name: String, cred: DropboxAccessTokenConfig): Unit = {
val dropboxConfig = LocationConfig.newBuilder().setDropboxAccessToken(cred).build()
locationConfig(name, dropboxConfig)
}

def option(key: String, value: String): Unit = {
programOptions.put(key, value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ import raw.testing.tags.TruffleTests
// no credentials
test(
s"""MySQL.InferAndRead("${mysqlCreds.getDatabase}", "$mysqlTable" )""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: ${mysqlCreds.getDatabase}""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: ${mysqlCreds.getDatabase}""".stripMargin))

test(
s"""MySQL.Read("${mysqlCreds.getDatabase}", "$mysqlTable",
| type collection(record(a: int, b: int, c: double, d: double, x: int, y: string))
|)""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: ${mysqlCreds.getDatabase}""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: ${mysqlCreds.getDatabase}""".stripMargin))

// server does not exist
test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ import raw.testing.tags.TruffleTests
// no credentials
test(
s"""Oracle.InferAndRead("$oracleDb", "$oracleSchema", "$oracleTable" )""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: $oracleDb""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: $oracleDb""".stripMargin))

test(
s"""Oracle.Read("$oracleSchema", "rdbmstest", "$oracleTable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ import raw.testing.tags.TruffleTests
// no credentials
test(
s"""PostgreSQL.InferAndRead("${pgsqlCreds.getDatabase}", "$pgSchema", "$pgTable" )""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: ${pgsqlCreds.getDatabase}""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: ${pgsqlCreds.getDatabase}""".stripMargin))

test(
s"""PostgreSQL.Read("${pgsqlCreds.getDatabase}", "$pgSchema", "$pgTable",
| type collection(record(a: int, b: int, c: double, d: double, x: int, y: string))
|)""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: ${pgsqlCreds.getDatabase}""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: ${pgsqlCreds.getDatabase}""".stripMargin))

// server does not exist
test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ import raw.testing.tags.TruffleTests
// no credentials
test(
s"""SQLServer.InferAndRead("$sqlServDb", "$sqlServSchema", "$sqlServTable" )""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: rawtest""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: rawtest""".stripMargin))

test(
s"""SQLServer.Read("$sqlServDb", "$sqlServSchema", "$sqlServTable",
| type collection(record(a: int, b: int, c: double, d: double, x: int, y: string))
|)""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: $sqlServDb""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: $sqlServDb""".stripMargin))

// server does not exist
test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ import raw.testing.tags.TruffleTests
s"""Snowflake.InferAndRead("${snowflakeCreds.getDatabase}", "$snowflakeSchema", "$snowflakeMainTable" )""".stripMargin
)(it =>
it should runErrorAs(
s"""unknown database credential: ${snowflakeCreds.getDatabase}""".stripMargin
s"""unknown credential: ${snowflakeCreds.getDatabase}""".stripMargin
)
)

test(
s"""Snowflake.Read("${snowflakeCreds.getDatabase}", "$snowflakeSchema", "$snowflakeMainTable",
| type collection(record(a: int, b: int, c: double, d: double, x: int, y: string))
|)""".stripMargin
)(it => it should runErrorAs(s"""unknown database credential: ${snowflakeCreds.getDatabase}""".stripMargin))
)(it => it should runErrorAs(s"""unknown credential: ${snowflakeCreds.getDatabase}""".stripMargin))

// server does not exist
test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package raw.compiler.rql2.tests.regressions.credentials

import raw.compiler.rql2.truffle.Rql2TruffleCompilerTestContext
import raw.protocol.DropboxAccessTokenConfig
import raw.testing.tags.TruffleTests

@TruffleTests class RD4445Test extends Rql2TruffleCompilerTestContext {
Expand All @@ -21,7 +22,7 @@ import raw.testing.tags.TruffleTests

property("raw.sources.dropbox.clientId", dropboxClientId)

httpHeaders("rawlabs-dropbox", Map("Authorization" -> ("Bearer " + dropboxLongLivedAccessToken)))
dropbox("rawlabs-dropbox", DropboxAccessTokenConfig.newBuilder().setAccessToken(dropboxLongLivedAccessToken).build())

test("""String.ReadLines("dropbox://rawlabs-dropbox/New folder/New Document")""")(
_ should evaluateTo("""["Hello", "World", "Again!"]""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class MySQLInferAndReadEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not a MySQL server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlTableInferrerProperties(location, None))
Expand Down Expand Up @@ -395,7 +395,7 @@ class MySQLInferAndQueryEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not a MySQL server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlQueryInferrerProperties(location, query, None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class OracleInferAndReadEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not an Oracle server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlTableInferrerProperties(location, None))
Expand Down Expand Up @@ -424,7 +424,7 @@ class OracleInferAndQueryEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not an Oracle server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlQueryInferrerProperties(location, query, None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class PostgreSQLInferAndReadEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not a PostgreSQL server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlTableInferrerProperties(location, None))
Expand Down Expand Up @@ -434,7 +434,7 @@ class PostgreSQLInferAndQueryEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not an Oracle server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlQueryInferrerProperties(location, query, None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class SQLServerInferAndReadEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not an Oracle server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlTableInferrerProperties(location, None))
Expand Down Expand Up @@ -436,7 +436,7 @@ class SQLServerInferAndQueryEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not an Oracle server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlQueryInferrerProperties(location, query, None))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class SnowflakeInferAndReadEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not a Snowflake server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlTableInferrerProperties(location, None))
Expand Down Expand Up @@ -502,7 +502,7 @@ class SnowflakeInferAndQueryEntry extends SugarEntryExtension {
programContext.settings
)
case Some(_) => return Left("not a Snowflake server")
case None => return Left(s"unknown database credential: $db")
case None => return Left(s"unknown credential: $db")
}
}
Right(SqlQueryInferrerProperties(location, query, None))
Expand Down

0 comments on commit cbcfab8

Please sign in to comment.