You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2010/07/21 07:28:51 UTC

svn commit: r966096 - in /tuscany/sca-cpp/trunk: modules/wsgi/composite.py samples/store-gae/htdocs/test/ samples/store-gae/htdocs/test/getcatalog-result.txt samples/store-gae/server-test

Author: jsdelfino
Date: Wed Jul 21 05:28:51 2010
New Revision: 966096

URL: http://svn.apache.org/viewvc?rev=966096&view=rev
Log:
Add a test of the password protected python store sample.

Added:
    tuscany/sca-cpp/trunk/samples/store-gae/htdocs/test/
    tuscany/sca-cpp/trunk/samples/store-gae/htdocs/test/getcatalog-result.txt
Modified:
    tuscany/sca-cpp/trunk/modules/wsgi/composite.py
    tuscany/sca-cpp/trunk/samples/store-gae/server-test

Modified: tuscany/sca-cpp/trunk/modules/wsgi/composite.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/wsgi/composite.py?rev=966096&r1=966095&r2=966096&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/wsgi/composite.py (original)
+++ tuscany/sca-cpp/trunk/modules/wsgi/composite.py Wed Jul 21 05:28:51 2010
@@ -118,23 +118,27 @@ def postArgs(a):
     l = car(a);
     return cons(l, postArgs(cdr(a)))
 
-# Return the URL of the logout page
-def logout(ruri):
+# Return the URL used to sign out
+def signout(ruri):
     try:
         from google.appengine.api import users
         return users.create_logout_url(ruri)
     except:
         return None
 
+# Return the URL used to sign in
+def signin(ruri):
+    try:
+        from google.appengine.api import users
+        return users.create_login_url(ruri)
+    except:
+        return None
+
 # WSGI application function
 def application(e, r):
     m = requestMethod(e)
     fpath = requestPath(e)
 
-    # Debug hook
-    if fpath == "/debug":
-        return result(e, r, 200, (("Content-type", "text/plain"),), ("Debug",))
-
     # Serve static files
     if m == "GET":
         if fpath.endswith(".html"):
@@ -146,11 +150,19 @@ def application(e, r):
         if fpath == "/":
             return result(e, r, 301, (("Location", "/index.html"),))
 
-    # Logout
-    if fpath == "/logout":
-        redir = logout("/")
-        if redir:
-            return result(e, r, 301, (("Location", redir),))
+        # Debug hook
+        if fpath == "/debug":
+            return result(e, r, 200, (("Content-type", "text/plain"),), ("Debug",))
+
+        # Sign in and out
+        if fpath == "/login":
+            redir = signin("/")
+            if redir:
+                return result(e, r, 301, (("Location", redir),))
+        if fpath == "/logout":
+            redir = signout(signin("/"))
+            if redir:
+                return result(e, r, 301, (("Location", redir),))
 
     # Find the requested component
     path = tokens(fpath)

Added: tuscany/sca-cpp/trunk/samples/store-gae/htdocs/test/getcatalog-result.txt
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-gae/htdocs/test/getcatalog-result.txt?rev=966096&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-gae/htdocs/test/getcatalog-result.txt (added)
+++ tuscany/sca-cpp/trunk/samples/store-gae/htdocs/test/getcatalog-result.txt Wed Jul 21 05:28:51 2010
@@ -0,0 +1 @@
+{"id":1,"result":[{"price":2.9900000000000002,"javaClass":"services.Item","currencyCode":"USD","name":"Apple","currencySymbol":"$"},{"price":3.5499999999999998,"javaClass":"services.Item","currencyCode":"USD","name":"Orange","currencySymbol":"$"},{"price":1.55,"javaClass":"services.Item","currencyCode":"USD","name":"Pear","currencySymbol":"$"}]}
\ No newline at end of file

Modified: tuscany/sca-cpp/trunk/samples/store-gae/server-test
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-gae/server-test?rev=966096&r1=966095&r2=966096&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-gae/server-test (original)
+++ tuscany/sca-cpp/trunk/samples/store-gae/server-test Wed Jul 21 05:28:51 2010
@@ -25,12 +25,30 @@ curl_prefix=`cat $here/../../modules/htt
 ./start 2>/dev/null
 sleep 2
 
-# Test HTTP GET
+# Test HTTP GET (with authentication)
 mkdir -p tmp
-$curl_prefix/bin/curl -L http://localhost:8090/ 2>/dev/null >tmp/login.html
-grep "Login" tmp/login.html >/dev/null
+$curl_prefix/bin/curl -L -c tmp/cookies.txt -b tmp/cookies.txt "http://localhost:8090/_ah/login?email=test@example.com&action=Login&continue=http://localhost:8090/" 2>/dev/null >tmp/index.html
+diff tmp/index.html htdocs/index.html
 rc=$?
 
+# Test Catalog
+if [ "$rc" = "0" ]; then
+    $curl_prefix/bin/curl -b tmp/cookies.txt http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/getcatalog-request.txt >tmp/getcatalog-result.txt 2>/dev/null
+    diff tmp/getcatalog-result.txt htdocs/test/getcatalog-result.txt
+    rc=$?
+fi
+
+# Test Shopping Cart
+if [ "$rc" = "0" ]; then
+    $curl_prefix/bin/curl -b tmp/cookies.txt http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null
+    rc=$?
+fi
+if [ "$rc" = "0" ]; then
+    $curl_prefix/bin/curl -b tmp/cookies.txt http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null
+    grep "3.55" tmp/shopping-cart-feed.xml >/dev/null
+    rc=$?
+fi
+
 # Cleanup
 ./stop
 sleep 2