change cli to curl for integration script (#66)

diff --git a/README.md b/README.md
index 27f3740..1653c3c 100644
--- a/README.md
+++ b/README.md
@@ -503,11 +503,7 @@
 This will disable SSL/TLS verification for all SSL communication.
 
 Alternatively, you can run the `prepIntegrationTests.sh` script using guest credentials or by specifying specific credentials.  
-Run the script with guest credentials:  
-```
-./test/integration/prepIntegrationTests.sh guest
-```  
-Run the script with specific credentials:  
+Run the script with openwhisk credentials:  
 ```
 ./test/integration/prepIntegrationTests.sh <your key in the form of ABCD:EFGH> <openwhisk instance hostname> <openwhisk namespace> <api gatewaytoken>
 ```  
@@ -524,6 +520,6 @@
 1 `npm run code-coverage-build`  
 
 To generate combined reports of both the unit and integration tests, run the following command:  
-2 `npm run code-coverage-run`  
+2 `npm run code-coverage-run <key> <host> <namespace> <token> <options>`  
 
 The report is viewable under `/coverage`. Click **`/coverage/index.html`** to view the full report.  
diff --git a/test/integration/prepIntegrationTests.sh b/test/integration/prepIntegrationTests.sh
index 16693ce..32cd582 100755
--- a/test/integration/prepIntegrationTests.sh
+++ b/test/integration/prepIntegrationTests.sh
@@ -1,14 +1,8 @@
 #!/bin/bash
 #set -e
-#Usage: ./test/integration/prepIntegrationTests.sh <yourapikeyintheformofABCD:EFGH> <openwhis hostname> <openwhisk namespace> <api gatewaytoken>
+#Usage: ./test/integration/prepIntegrationTests.sh <yourapikeyintheformofABCD:EFGH> <openwhis hostname> <openwhisk namespace> <api gatewaytoken> <optional "insecure">
 # Run from the incubator-openwhisk-client-js
 
-# Make sure wsk is installed; exit if wsk is not available.
-if ! type "wsk" > /dev/null; then
-  echo "Exiting program; wsk is not installed on the system. Cannot preform tests"
-  exit 1
-fi
-
 # Assert NODEJS6/NPM3 or greater is default node/npm version
 NODE_VERSION_MAJOR=`node --version | awk -Fv '{print $2}' | awk -F. '{print $1}'`
 if [ ${NODE_VERSION_MAJOR} -lt 6 ]; then
@@ -21,32 +15,17 @@
 override_host="$2"
 override_namespace="$3"
 override_token="$4"
+insecurecred="$5"
 iflag=""
 kflag=""
 
-function getvalue {
-  content="$1"
-  search="$2"
-  result="$3"
-  result=$(echo "$content" | grep "$search" | awk '{print $NF}')
-  return 0
-}
-
-if [ $override_key == "guest" ]; then
-  echo "getting guest user credentials"
+if [ $insecurecred == "insecure" ]; then
+  echo "INSECURE MODE!"
   iflag="-i"
   kflag="-k"
-  propInfo=$(wsk -i property get)
-  getvalue "$propInfo" "whisk auth" "$result"
-  override_key="$result"
-  getvalue "$propInfo" "whisk API host" "$result"
-  override_host="$result"
   override_namespace="guest"
-  override_token=""
-
 fi
 
-
 #If they exist, export these values (tests use a global)
 if [ -n "$override_key" ] && [ -n "$override_host" ] && [ -n "$override_namespace" ] ; then
   echo "found key, host, namespace and token"
@@ -78,9 +57,9 @@
 echo "function main() {return {payload: 'Hello world'};}" > temp/tests.js
 
 echo "Create wsk actions and triggers for use by tests"
-wsk $iflag action update hello temp/tests.js
-wsk $iflag action update tests temp/tests.js
-wsk $iflag trigger update sample
+curl -s --output /dev/null $kflag -u $__OW_API_KEY  -d '{"namespace":"'"$__OW_NAMESPACE"'","name":"hello","exec":{"kind":"nodejs:6","code":"function main() { return {payload:\"Hello world\"}}"}}' -X PUT -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/hello?overwrite=true
+curl -s --output /dev/null $kflag -u $__OW_API_KEY  -d '{"namespace":"'"$__OW_NAMESPACE"'","name":"tests","exec":{"kind":"nodejs:6","code":"function main() { return {payload:\"Hello world\"}}"}}' -X PUT -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/tests?overwrite=true
+curl -s --output /dev/null $kflag -u $__OW_API_KEY -d '{"name":"sample"}' -X PUT -H "Content-Type: application/json"  https://192.168.99.100/api/v1/namespaces/_/triggers/sample?overwrite=true
 
 #run tests
 echo "running tests"
@@ -91,30 +70,32 @@
 function cleanresources {
   verb="$1"
   name="$2"
-  wsk $iflag $verb get $name -s &>/dev/null
-  if [[ $PIPESTATUS -eq 0 ]]; then
-    wsk $iflag $verb delete $name
+
+  curlstatus=$(curl -s -i $kflag -u $__OW_API_KEY -X GET -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/$verb/$name)
+  statusheader=$(echo "$curlstatus" | awk 'NR==1{print $0; exit}')
+  if [[ $statusheader == *"200"* ]]; then
+    echo "200 status code found; now deleteing"
+    curl -s -i $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/$verb/$name
   fi
 }
 
 #clean up artifacts generated during a bad-testRun
 echo "clean resources"
-cleanresources action routeAction
-cleanresources action random_package_action_test
-cleanresources action random_action_test
-cleanresources action random_action_params_test
-cleanresources action random_update_tested
-cleanresources trigger sample_feed_trigger
-cleanresources trigger sample_rule_trigger
-cleanresources trigger random_trigger_test
-cleanresources rule random_rule_test
-#wsk api delete /testing
+cleanresources actions routeAction
+cleanresources actions random_package_action_test
+cleanresources actions random_action_test
+cleanresources actions random_action_params_test
+cleanresources actions random_update_tested
+cleanresources triggers sample_feed_trigger
+cleanresources triggers sample_rule_trigger
+cleanresources triggers random_trigger_test
+cleanresources rules random_rule_test
 
 #cleanup workspace
 rm -rf temp
-wsk $iflag action delete hello
-wsk $iflag action delete tests
-wsk $iflag trigger delete sample
+curl -s --output /dev/null $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/hello
+curl -s --output /dev/null $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/actions/tests
+curl -s --output /dev/null $kflag -u $__OW_API_KEY -X DELETE -H "Content-Type: application/json" https://$__OW_API_HOST/api/v1/namespaces/$__OW_NAMESPACE/triggers/sample
 
 echo "script finished"
 
diff --git a/tools/merge-coverage.sh b/tools/merge-coverage.sh
index 03da3db..76330b6 100755
--- a/tools/merge-coverage.sh
+++ b/tools/merge-coverage.sh
@@ -1,5 +1,15 @@
 #!/bin/bash
-runningEnv="$1"
+key="$1"
+host="$2"
+namespace="$3"
+token="$4"
+runningEnv="$5"
+insecure=""
+
+if [[ "$runningEnv" == *"insecure"* ]] ; then
+  insecure="insecure"
+fi
+
 
 tempDir="coveragetemp"
 mkdir $tempDir
@@ -11,7 +21,7 @@
 unitstatus="$PIPESTATUS"
 mv .nyc_output/* $tempDir/unit
 
-node ./node_modules/nyc/bin/nyc.js ./test/integration/prepIntegrationTests.sh guest
+node ./node_modules/nyc/bin/nyc.js ./test/integration/prepIntegrationTests.sh $key $host $namespace $token $insecure
 integrationstatus="$PIPESTATUS"
 mv .nyc_output/* $tempDir/integration
 
@@ -21,7 +31,7 @@
 rm -rf $tempDir
 
 # generate the HTML report from the merged results
-if [ "$runningEnv" == "travis" ] ; then
+if [[ "$runningEnv" == *"travis"* ]] ; then
   npm run coverage
 fi
 
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
index 09028b4..3aaf856 100755
--- a/tools/travis/build.sh
+++ b/tools/travis/build.sh
@@ -10,7 +10,7 @@
 # Install OpenWhisk
 cd $WHISKDIR/ansible
 
-ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=openwhisk"
+ANSIBLE_CMD="ansible-playbook -i environments/local -e docker_image_prefix=openwhisk "
 
 $ANSIBLE_CMD setup.yml
 $ANSIBLE_CMD prereq.yml
@@ -19,29 +19,21 @@
 $ANSIBLE_CMD apigateway.yml
 
 cd $WHISKDIR
-./gradlew :tools:cli:distDocker -PdockerImagePrefix=openwhisk
-
+ ./gradlew  -PdockerImagePrefix=openwhisk
 cd $WHISKDIR/ansible
 
 $ANSIBLE_CMD wipe.yml
-$ANSIBLE_CMD openwhisk.yml
+$ANSIBLE_CMD openwhisk.yml  -e '{"openwhisk_cli":{"installation_mode":"remote","remote":{"name":"OpenWhisk_CLI","dest_name":"OpenWhisk_CLI","location":"https://github.com/apache/incubator-openwhisk-cli/releases/download/latest"}}}'
 $ANSIBLE_CMD postdeploy.yml
 
 cd $WHISKDIR
 cat whisk.properties
 
-# Set Environment
-export OPENWHISK_HOME=$WHISKDIR
-
-# Set up CLI tool used by prereq script
-sudo cp $WHISKDIR/bin/wsk /usr/bin/wsk
-
 edgehost=$(cat $WHISKDIR/whisk.properties | grep edge.host= | sed s/edge\.host=//)
-wsk property set --apihost $edgehost
-wsk property set --auth "$(cat $WHISKDIR/ansible/files/auth.guest)"
+key=$(cat $WHISKDIR/ansible/files/auth.guest)
 
 # Test
 cd $ROOTDIR
 npm install --dev
 npm run code-coverage-build
-npm run code-coverage-run travis
+npm run code-coverage-run $key $edgehost guest true "travis,insecure"