Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 31b5417

Browse files
falkzollsomaya10
authored andcommitted
Update credentials.json.enc and testDB2Service.py. (#102)
* Update credentials.json.enc and testDB2Service.py. * Switch decode credentials, fix test cases. - Switch decoding key for credentials. - Adapt tests to changes in openwhisk repository. * Revert change. * Build binary artifacts required for the tests. * Use generated python.zip. * Provide Path instead of File. * Switch to getAbsolutePath(). * Explicitly call :tests:buildArtifacts. * Switch back to python.zip from open. * Remove buildArtifacts. * Remove python.zip resources. * Add test resources removed from openwhisk. * Remove unused import. * Add missing File import. * Move actions to resources directory. * Also build openwhisk test artifacts. * Cleanup scripts. * Some cleanup. * Change username/password in watson tests to apikey. - Watson updated its instances to IAM. Therefore they now use apikey instead of username/password.
1 parent d69a7fe commit 31b5417

File tree

14 files changed

+57
-17
lines changed

14 files changed

+57
-17
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ notifications:
1212
secure: Yc9ZlTaxhcZT3GWkYyiKpREEORBDLNoTHRqBJNOKvIF1oOCZPH0E9KqaJewwcoSno9G8yhd239kzYtv34moAxYdyKe89SomiH+9wFFpjlS7Ge28+VTWv8yr1EL6pUMW7rJDDODeKxwEHMkdCMARFLrYlQ8xM9quWrc98zqULwusIZpGyVwT3K/4PpWL1OH7D9d0Ain3jods1t7hEzlt8XykLhxpu20bKtxo/0rBJre7f6oCCjEARsHJkvx31VuuZAp5cCLOXPc22Fsd7kqOzzGpsLQICURwUqf7DR8qWyFyXT3QnfJwc2uYXE1yj6SOGxHV1jXOSIymiUFD+8afHlm4SBnqo0UhAIf1z3AJ7r+MSsCTLK7w7kY1WjfOXCK74hiNzS8WmzZJ7C3cVCKYEaxYDDbpUqx9b1+gRaf+acJEuvkMLlkJo5Rze+njdeR9RZbR7i0KR3OCLjXDlu87P2orq6iMNCTDs1FtXlOFeeL42o1YcL1CCKnVXr9feGDSmpZ7Y1ypih+yoeFRYrdG/rPEcgppPXCZBbCWqlzAoRMDrFck+weHTCyMzm16moz2dAxCulm8TrUlb5z4ClbasD6sfdaSFskQtpnW6JtG9gIQt6pfJGkHzMV3Js06sUTNhRWtiLXyUJAftN2xq1skFoMR5beg2a1H9+OKeS03a45E=
1313

1414
before_install:
15-
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_10110adb91b4_key -iv $encrypted_10110adb91b4_iv -in tests/credentials.json.enc -out tests/credentials.json -d; fi'
15+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K "$encrypted_8D2E480FC532_key" -iv "$encrypted_8D2E480FC532_iv" -in tests/credentials.json.enc -out tests/credentials.json -d; fi'
1616
- "./tools/travis/setup.sh"
1717
install: true
1818
script:

tests/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ dependencies {
3838
tasks.withType(ScalaCompile) {
3939
scalaCompileOptions.additionalParameters = gradle.scala.compileFlags
4040
}
41+
42+
task buildArtifacts(type:Exec) {
43+
workingDir 'src/test/resources'
44+
commandLine './build.sh'
45+
}
46+
47+
tasks.withType(Test) {
48+
dependsOn buildArtifacts
49+
}
50+
51+
testClasses.dependsOn(buildArtifacts)

tests/credentials.json.enc

800 Bytes
Binary file not shown.

tests/dat/db2/testDB2Service.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ def main(args):
1111
print ("Connection failed.")
1212
return {"error":"Error connecting to db2"}
1313

14-
# Select from TestTable (the row just inserted)
15-
cmd = "SELECT HISP_DESC FROM SAMPLES.HISPANIC_ORIGIN WHERE HISP_CODE='03'"
14+
# Select from TestTable (the row just inserted).
15+
#
16+
# Due to the db2 lite plan we use, the schema name is fixed to be
17+
# the same as the username. We cut the value of the UID field
18+
# in the ssldsn to get it and insert it in the select statement.
19+
# The ssldsn looks like this:
20+
# ssldsn="DATABASE=BLUDB;HOSTNAME=dashdb-xxxx.services.dal.bluemix.net;PORT=50001;PROTOCOL=TCPIP;UID=yyyyyyy;PWD=<hidden>;"
21+
#
22+
ssldsndict = dict(x.split("=") for x in ssldsn.rstrip(";").split(";"))
23+
print("user={}".format(ssldsndict["UID"]))
24+
25+
cmd = "SELECT HISP_DESC FROM {}.HISPANIC_ORIGIN WHERE HISP_CODE='03'".format(ssldsndict["UID"])
1626
result = ibm_db.exec_immediate(conn, cmd)
1727

1828
if not result:
@@ -27,4 +37,4 @@ def main(args):
2737
if __name__ == "__main__":
2838
# execute only if run as a script
2939
input = {"__bx_creds":{"dashDB":{"ssldsn":"<ssldsn from credentials>"}}}
30-
print(main(input))
40+
print(main(input))

tests/dat/watson/testWatsonService.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def main(args):
88
language_translator = LanguageTranslatorV3(
99
version="2018-05-01",
1010
url=args.get("url"),
11-
username=args.get("username"),
12-
password=args.get("password"))
11+
username="APIKey",
12+
password=args.get("apikey"))
1313

1414
translation = language_translator.translate(text='Hello', model_id='en-es')
1515
if LooseVersion(sdk_version) < LooseVersion('2.0.0'):
@@ -20,6 +20,5 @@ def main(args):
2020
if __name__ == "__main__":
2121
# execute only if run as a script
2222
input = {"url":"<url from credentials>",
23-
"username":"<username from credentials>",
24-
"password":"<password from credentials>"}
23+
"apikey":"<apikey from credentials>"}
2524
print(main(input))

tests/src/test/resources/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# build the necessary resources for the testcases
6+
# this is not implemented, yet
7+
# it will look like this:
8+
# (cd python-zip && zip ../python.zip -r .)
3.48 MB
Binary file not shown.
3.63 MB
Binary file not shown.
807 Bytes
Binary file not shown.
586 KB
Binary file not shown.

0 commit comments

Comments
 (0)