incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1467947 - in /sling/trunk/contrib/extensions/muppet/muppet-sling: pom.xml src/test/java/org/apache/sling/muppet/sling/LoginRuleBuilderTest.java
Date Mon, 15 Apr 2013 11:56:01 GMT
Author: bdelacretaz
Date: Mon Apr 15 11:56:01 2013
New Revision: 1467947

URL: http://svn.apache.org/r1467947
Log:
SLING-2822 - LoginRuleBuilderTest added

Added:
    sling/trunk/contrib/extensions/muppet/muppet-sling/src/test/java/org/apache/sling/muppet/sling/LoginRuleBuilderTest.java
Modified:
    sling/trunk/contrib/extensions/muppet/muppet-sling/pom.xml

Modified: sling/trunk/contrib/extensions/muppet/muppet-sling/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/muppet/muppet-sling/pom.xml?rev=1467947&r1=1467946&r2=1467947&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/muppet/muppet-sling/pom.xml (original)
+++ sling/trunk/contrib/extensions/muppet/muppet-sling/pom.xml Mon Apr 15 11:56:01 2013
@@ -79,6 +79,7 @@
         <dependency>
             <groupId>javax.jcr</groupId>
             <artifactId>jcr</artifactId>
+            <version>2.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -124,5 +125,11 @@
             <version>4.8.1</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.testing</artifactId>
+            <version>2.0.14</version>
+            <scope>test</scope>
+        </dependency>
      </dependencies>
 </project>

Added: sling/trunk/contrib/extensions/muppet/muppet-sling/src/test/java/org/apache/sling/muppet/sling/LoginRuleBuilderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/muppet/muppet-sling/src/test/java/org/apache/sling/muppet/sling/LoginRuleBuilderTest.java?rev=1467947&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/muppet/muppet-sling/src/test/java/org/apache/sling/muppet/sling/LoginRuleBuilderTest.java
(added)
+++ sling/trunk/contrib/extensions/muppet/muppet-sling/src/test/java/org/apache/sling/muppet/sling/LoginRuleBuilderTest.java
Mon Apr 15 11:56:01 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you 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.
+ */
+package org.apache.sling.muppet.sling;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Field;
+
+import org.apache.sling.commons.testing.jcr.RepositoryProvider;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.muppet.api.EvaluationResult;
+import org.apache.sling.muppet.api.Rule;
+import org.apache.sling.muppet.sling.impl.rules.LoginRuleBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoginRuleBuilderTest {
+    private LoginRuleBuilder builder;
+    
+    @Before
+    public void setup() throws Exception {
+        builder = new LoginRuleBuilder();
+        final Field f = builder.getClass().getDeclaredField("repository");
+        f.setAccessible(true);
+        final SlingRepository r = RepositoryProvider.instance().getRepository();
+        f.set(builder, r);
+    }
+
+    @Test
+    public void testAdminLoginSucceeds() {
+        final Rule r = builder.buildRule("sling", "login", "admin#admin", "LOGIN_OK");
+        assertEquals("Expecting admin login to succeed", EvaluationResult.Status.OK, r.execute());
+    }
+    
+    @Test
+    public void testAdminBadPasswordFails() {
+        final Rule r = builder.buildRule("sling", "login", "admin#bad", "OK");
+        assertEquals("Expecting admin login to succeed", EvaluationResult.Status.ERROR, r.execute());
+    }
+    
+    @Test
+    public void testFooLoginFails() {
+        final Rule r = builder.buildRule("sling", "login", "foo#bar", "OK");
+        assertEquals("Expecting admin login to succeed", EvaluationResult.Status.ERROR, r.execute());
+    }
+}



Mime
View raw message