diff --git a/.travis.yml b/.travis.yml index 69fb0cd9adb..09bd709a6dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ addons: - expect before_install: - openssl aes-256-cbc -K $encrypted_37a4f399de75_key -iv $encrypted_37a4f399de75_iv -in service-account.json.enc -out service-account.json -d + && openssl aes-256-cbc -K $encrypted_37a4f399de75_key -iv $encrypted_37a4f399de75_iv -in service-account.json.enc -out appengine/firebase-event-proxy/gae-firebase-event-proxy/src/main/webapp/gae-firebase-secrets.json -d && export GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/service-account.json GCLOUD_PROJECT=cloud-samples-tests || true # Skip the install step, since Maven will download the dependencies we need diff --git a/appengine/firebase-event-proxy/README.md b/appengine/firebase-event-proxy/README.md index eeb8b4ac107..880c26ea1da 100644 --- a/appengine/firebase-event-proxy/README.md +++ b/appengine/firebase-event-proxy/README.md @@ -32,7 +32,7 @@ mvn appengine:devserver ### Python App Engine Listener ``` cd gae-firebase-listener-python -dev_appserver . +dev_appserver.py . ``` ## Deploying diff --git a/appengine/firebase-event-proxy/gae-firebase-event-proxy/src/main/java/com/example/GaeFirebaseEventProxy/FirebaseEventProxy.java b/appengine/firebase-event-proxy/gae-firebase-event-proxy/src/main/java/com/example/GaeFirebaseEventProxy/FirebaseEventProxy.java index bd706ba03e4..fd2d1d0358c 100644 --- a/appengine/firebase-event-proxy/gae-firebase-event-proxy/src/main/java/com/example/GaeFirebaseEventProxy/FirebaseEventProxy.java +++ b/appengine/firebase-event-proxy/gae-firebase-event-proxy/src/main/java/com/example/GaeFirebaseEventProxy/FirebaseEventProxy.java @@ -73,7 +73,7 @@ public void onDataChange(DataSnapshot snapshot) { String json = new ObjectMapper().writeValueAsString(snapshot.getValue(false)); // Replace the URL with the url of your own listener app. - URL dest = new URL("http://gae-firebase-listener-python.appspot.com/log"); + URL dest = new URL("http://localhost:8080/log"); HttpURLConnection connection = (HttpURLConnection) dest.openConnection(); connection.setRequestMethod("POST"); connection.setDoOutput(true); diff --git a/appengine/firebase-event-proxy/gae-firebase-listener-python/main.py b/appengine/firebase-event-proxy/gae-firebase-listener-python/main.py index 49145bbd749..e7bee2fc525 100644 --- a/appengine/firebase-event-proxy/gae-firebase-listener-python/main.py +++ b/appengine/firebase-event-proxy/gae-firebase-listener-python/main.py @@ -29,7 +29,7 @@ def post(self): user = self.request.headers.get('X-Appengine-Inbound-Appid', None) if user and user in allowed_users: firebaseSnapshot = self.request.params['fbSnapshot'] - print firebaseSnapshot + print "Got data: %s" % firebaseSnapshot else: print "Got unauthenticated user: %s" % user diff --git a/appengine/firebase-event-proxy/run_tests.sh b/appengine/firebase-event-proxy/run_tests.sh new file mode 100755 index 00000000000..b8ff6c061da --- /dev/null +++ b/appengine/firebase-event-proxy/run_tests.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +set -x + +# Expected to run this file from root of GitHub project. +( +cd appengine/firebase-event-proxy/ + +expect -c ' +spawn dev_appserver.py gae-firebase-listener-python +set python_listener_id $spawn_id +spawn mvn --file gae-firebase-event-proxy appengine:devserver -Dappengine.port=8888 +set event_proxy_id $spawn_id +expect { + # Listen for Got data from Python listener + -i $python_listener_id "Got data" { + exit + } -i $event_proxy_id "Sent" { + send_user Event proxy sent data successful + } +} +sleep 20 +exit 1 +' +) diff --git a/travis.sh b/travis.sh index f7677604fab..7e23edeebb0 100755 --- a/travis.sh +++ b/travis.sh @@ -36,3 +36,4 @@ for testdir in ${devserver_tests[@]} ; do ./java-repo-tools/test-devserver.sh "${testdir}" done +appengine/firebase-event-proxy/run_tests.sh