Fix sbt miminmum memory usage. webid
authorHenry Story <henry.story@bblfish.net>
Thu, 03 Nov 2011 18:20:26 +0100
branchwebid
changeset 119 956b66216b0c
parent 107 3bb89aaaab51
Fix sbt miminmum memory usage.
And some other minor syntactic naming fixes
sbt
src/main/scala/auth/Authz.scala
src/test/scala/auth/CreateWebIDSpec.scala
src/test/scala/auth/secure_specs.scala
--- a/sbt	Sun Oct 30 20:42:26 2011 +0100
+++ b/sbt	Thu Nov 03 18:20:26 2011 +0100
@@ -38,5 +38,5 @@
 fi
 
 # tweak this line according to your needs
-java -Xmx512M -jar -Dfile.encoding=UTF8 -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m "$dir/$sbt" "$@"
+java -Xms512M -jar -Dfile.encoding=UTF8 -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m "$dir/$sbt" "$@"
 
--- a/src/main/scala/auth/Authz.scala	Sun Oct 30 20:42:26 2011 +0100
+++ b/src/main/scala/auth/Authz.scala	Thu Nov 03 18:20:26 2011 +0100
@@ -87,7 +87,7 @@
 
 
   def protect(in: Req=>Res)(implicit  m: Manifest[Request]): Req=>Res =  {
-      case req @ HttpMethod(method) & Authoritative(url,_) if guard(method, url).allow(() => subject(req)) => in(req)
+      case req @ HttpMethod(method) & Authoritative(url,_) if guard(method, url).allows(() => subject(req)) => in(req)
       case _ => Unauthorized
     }
   
@@ -103,7 +103,7 @@
      * verify if the given request is authorized
      * @param subj function returning the subject to be authorized if the resource needs authorization
      */
-    def allow(subj: () => Option[Subject]): Boolean
+    def allows(subj: () => Option[Subject]): Boolean
   }
 
 }
@@ -115,7 +115,7 @@
   implicit val cache : WebCache = webCache
 
   def subject(req: Req) = req match {
-    case X509Claim(claim) => Option(claim)
+    case X509Claim(claim) => Some(claim)
     case _ => None
   }
 
@@ -144,7 +144,7 @@
 
 
 
-    def allow(subj: () => Option[Subject]) = {
+    def allows(subj: () => Option[Subject]) = {
       val r: Resource = rm.resource(new URL(url,".meta.n3"))
       val res: ValidationW[Boolean,Boolean] = for {
         model <- r.get() failMap { x => true }
@@ -157,9 +157,9 @@
           val res = for (qs <- exec) yield {
             val methods = qs.get("mode").toString match {
               case Read => List(GET)
-              case Write => List(PUT, POST)
+              case Write => List(PUT, POST, DELETE)
               case Control => List(POST)
-              case _ => List(GET, PUT, POST, DELETE) //nothing everything is allowed
+              case _ => List(GET, PUT, POST, DELETE) //nothing everything is allows
             }
             if (methods.contains(method)) Some((qs.get("agent"), qs.get("group")))
             else None
@@ -187,7 +187,7 @@
         } else false //
       }
       res.validation.fold()
-    } // end allow()
+    } // end allows()
 
 
   }
--- a/src/test/scala/auth/CreateWebIDSpec.scala	Sun Oct 30 20:42:26 2011 +0100
+++ b/src/test/scala/auth/CreateWebIDSpec.scala	Thu Nov 03 18:20:26 2011 +0100
@@ -90,7 +90,7 @@
        @prefix : <#> .
 
        <> a foaf:PersonalProfileDocument;
-          foaf:primaryTopic :me .
+          foaf:primaryTopic :jL .
 
        :jL a foaf:Person;
            foaf:name "Joe Lambda"@en .
@@ -140,7 +140,7 @@
    }
   
   
-   "PUTing a WebID Profile on /people/Lambda/" should {
+   "PUTing a WebID Profile 'Joe' on /people/Lambda/ " should {
      "return a 201" in {
        val httpCode = Http( webidProfile.secure.put(TURTLE, foaf) get_statusCode )
         httpCode must_== 201
@@ -188,7 +188,7 @@
 
        val httpCode = Http(
          webidProfile.secure.postSPARQL(updateQStr) get_statusCode )
-        httpCode must_== 200
+        httpCode must_== 200  //?
      }
 
      "create 3 more relations" in {
@@ -236,7 +236,7 @@
       httpCode must_== 401
     }
 
-    "access it as the user - allow him to add a friend" in {
+    "access it as the user - allows him to add a friend" in {
       testKeyManager.setId("JoeLambda")
 
 /*    The code below was very useful to help me debug this.
--- a/src/test/scala/auth/secure_specs.scala	Sun Oct 30 20:42:26 2011 +0100
+++ b/src/test/scala/auth/secure_specs.scala	Thu Nov 03 18:20:26 2011 +0100
@@ -73,7 +73,7 @@
   /**
    * Inject flexible behavior into the client ssl so that it does not
    * break on every localhost problem. It returns a key manager which can be used
-   * to allow the client to take on various guises
+   * to allows the client to take on various guises
    */
   def flexi(client: HttpClient, km: KeyManager): SSLContext = {