Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelbranco80 committed Aug 4, 2024
1 parent e48980b commit fb14ca5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ import scala.io.Source
object TestCredentials {

/////////////////////////////////////////////////////////////////////////////
// Dropbox Credentials
// HTTP Headers
/////////////////////////////////////////////////////////////////////////////

val dropboxLongLivedAccessToken = sys.env("RAW_DROPBOX_TEST_LONG_LIVED_ACCESS_TOKEN")
val dropboxClientId = sys.env("RAW_DROPBOX_TEST_CLIENT_ID")

/////////////////////////////////////////////////////////////////////////////
// S3 Credentials
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -92,10 +95,6 @@ object TestCredentials {
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")
Expand Down Expand Up @@ -128,6 +127,8 @@ trait Rql2CompilerTestContext

private val rdbmsServers = new mutable.HashMap[String, JdbcLocation]()

private val credHttpHeaders = new mutable.HashMap[String, Map[String, String]]()

protected val programOptions = new mutable.HashMap[String, String]()

def authorizedUser: InteractiveUser = InteractiveUser(Uid("janeUid"), "Jane Smith", "jane@example.com")
Expand All @@ -150,6 +151,10 @@ trait Rql2CompilerTestContext
rdbmsServers.put(name, db)
}

def httpHeaders(name: String, headers: Map[String, String]): Unit = {
credHttpHeaders.put(name, headers)
}

def option(key: String, value: String): Unit = {
programOptions.put(key, value)
}
Expand Down Expand Up @@ -576,7 +581,7 @@ trait Rql2CompilerTestContext
this.runnerScopes ++ scopes,
secrets.toMap,
rdbmsServers.toMap,
Map.empty, // http headers
credHttpHeaders.toMap,
s3Credentials.toMap,
this.options ++ options ++ programOptions,
None, // jdbcUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait LocationPackageTest extends Rql2CompilerTestContext {

import raw.compiler.rql2.tests.TestCredentials._

oauth(authorizedUser, "dropbox-refresh-token", dropboxRefreshTokenCredential)
httpHeaders("dropbox-token", Map("Authorization" -> ("Bearer " + dropboxLongLivedAccessToken)))

s3Bucket(UnitTestPrivateBucket2, UnitTestPrivateBucket2Cred)

Expand All @@ -28,7 +28,7 @@ trait LocationPackageTest extends Rql2CompilerTestContext {
|String.Read(
| Http.Post(
| "https://api.dropboxapi.com/2/users/get_space_usage",
| authCredentialName = "dropbox-refresh-token"
| authCredentialName = "dropbox-token"
| )
|)""".stripMargin)(it => it should run)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ import raw.compiler.rql2.tests.Rql2CompilerTestContext

trait RD4445Test extends Rql2CompilerTestContext {

dropbox(authorizedUser, dropboxToken)
oauth(authorizedUser, "rawlabs-dropbox", dropboxAccessTokenCredential)
import raw.compiler.rql2.tests.TestCredentials._

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

httpHeaders("rawlabs-dropbox", Map("Authorization" -> ("Bearer " + dropboxLongLivedAccessToken)))

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 @@ -13,6 +13,12 @@
package raw.compiler.rql2.truffle

import raw.compiler.rql2.tests.Rql2CompilerTestContext
import raw.creds.api.CredentialsTestContext
import raw.creds.local.LocalCredentialsTestContext

// FIXME (msb): Rename this to TruffleTestContext
trait TruffleWithLocalCredentialsTestContext extends Rql2CompilerTestContext with Rql2TruffleCompilerServiceTestContext
trait TruffleWithLocalCredentialsTestContext
extends Rql2CompilerTestContext
with LocalCredentialsTestContext
with CredentialsTestContext
with Rql2TruffleCompilerServiceTestContext

0 comments on commit fb14ca5

Please sign in to comment.