deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-735 added test for multiple stereotypes annotated with @Secured
Date Sun, 05 Oct 2014 20:01:50 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master c32ece306 -> 4a7ef3d1e


DELTASPIKE-735 added test for multiple stereotypes annotated with @Secured


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/4a7ef3d1
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/4a7ef3d1
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/4a7ef3d1

Branch: refs/heads/master
Commit: 4a7ef3d1e7a31c30e3936bbafc9aad37db73b3b4
Parents: c32ece3
Author: gpetracek <gpetracek@apache.org>
Authored: Sun Oct 5 22:00:35 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Sun Oct 5 22:00:35 2014 +0200

----------------------------------------------------------------------
 .../secured/SecuredAnnotationTest.java          | 17 +++++++
 .../authorization/secured/SecuredBean4.java     | 32 +++++++++++++
 .../secured/SecuredBeanWithStereotype1.java     | 39 +++++++++++++++
 .../secured/SecuredBeanWithStereotype2.java     | 39 +++++++++++++++
 .../secured/TestAccessDecisionVoter1.java       | 47 ++++++++++++++++++
 .../secured/TestAccessDecisionVoter2.java       | 50 ++++++++++++++++++++
 6 files changed, 224 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a7ef3d1/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
index dd548c4..21f569d 100644
--- a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
@@ -94,4 +94,21 @@ public abstract class SecuredAnnotationTest
             Assert.fail("Unexpected Exception: " + e);
         }
     }
+
+    @Test
+    public void invocationOfMultipleSecuredStereotypes()
+    {
+        SecuredBean4 testBean = BeanProvider.getContextualReference(SecuredBean4.class, false);
+
+        TestAccessDecisionVoter1 voter1 = BeanProvider.getContextualReference(TestAccessDecisionVoter1.class,
false);
+        TestAccessDecisionVoter2 voter2 = BeanProvider.getContextualReference(TestAccessDecisionVoter2.class,
false);
+
+        Assert.assertFalse(voter1.isCalled());
+        Assert.assertFalse(voter2.isCalled());
+
+        Assert.assertEquals("result", testBean.getResult());
+
+        Assert.assertTrue(voter1.isCalled());
+        Assert.assertTrue(voter2.isCalled());
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a7ef3d1/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean4.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean4.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean4.java
new file mode 100644
index 0000000..73eb5a9
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean4.java
@@ -0,0 +1,32 @@
+/*
+ * 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 ASF 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.deltaspike.test.security.impl.authorization.secured;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+@SecuredBeanWithStereotype1
+@SecuredBeanWithStereotype2
+public class SecuredBean4
+{
+    public String getResult()
+    {
+        return "result";
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a7ef3d1/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype1.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype1.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype1.java
new file mode 100644
index 0000000..38c5c6f
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype1.java
@@ -0,0 +1,39 @@
+/*
+ * 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 ASF 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.deltaspike.test.security.impl.authorization.secured;
+
+import org.apache.deltaspike.security.api.authorization.Secured;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+
+@Retention(value = RUNTIME)
+@Target({TYPE, METHOD } )
+
+@Secured(TestAccessDecisionVoter1.class)
+public @interface SecuredBeanWithStereotype1
+{
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a7ef3d1/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype2.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype2.java
new file mode 100644
index 0000000..2ba374a
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype2.java
@@ -0,0 +1,39 @@
+/*
+ * 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 ASF 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.deltaspike.test.security.impl.authorization.secured;
+
+import org.apache.deltaspike.security.api.authorization.Secured;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+
+@Retention(value = RUNTIME)
+@Target({TYPE, METHOD } )
+
+@Secured(TestAccessDecisionVoter2.class)
+public @interface SecuredBeanWithStereotype2
+{
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a7ef3d1/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter1.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter1.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter1.java
new file mode 100644
index 0000000..fc6d6c8
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter1.java
@@ -0,0 +1,47 @@
+/*
+ * 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 ASF 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.deltaspike.test.security.impl.authorization.secured;
+
+import org.apache.deltaspike.security.api.authorization.AccessDecisionVoter;
+import org.apache.deltaspike.security.api.authorization.AccessDecisionVoterContext;
+import org.apache.deltaspike.security.api.authorization.SecurityViolation;
+
+import javax.enterprise.context.RequestScoped;
+import java.util.Collections;
+import java.util.Set;
+
+@RequestScoped
+public class TestAccessDecisionVoter1 implements AccessDecisionVoter
+{
+    private static final long serialVersionUID = 1331427301357439805L;
+
+    private boolean called;
+
+    @Override
+    public Set<SecurityViolation> checkPermission(AccessDecisionVoterContext accessDecisionVoterContext)
+    {
+        this.called = true;
+        return Collections.emptySet();
+    }
+
+    public boolean isCalled()
+    {
+        return called;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a7ef3d1/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter2.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter2.java
new file mode 100644
index 0000000..c506bf3
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/TestAccessDecisionVoter2.java
@@ -0,0 +1,50 @@
+/*
+ * 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 ASF 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.deltaspike.test.security.impl.authorization.secured;
+
+import org.apache.deltaspike.security.api.authorization.AccessDecisionVoter;
+import org.apache.deltaspike.security.api.authorization.AccessDecisionVoterContext;
+import org.apache.deltaspike.security.api.authorization.SecurityViolation;
+
+import javax.enterprise.context.RequestScoped;
+import javax.interceptor.InvocationContext;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+@RequestScoped
+public class TestAccessDecisionVoter2 implements AccessDecisionVoter
+{
+    private static final long serialVersionUID = 1331427301357439806L;
+
+    private boolean called;
+
+    @Override
+    public Set<SecurityViolation> checkPermission(AccessDecisionVoterContext accessDecisionVoterContext)
+    {
+        this.called = true;
+        return Collections.emptySet();
+    }
+
+    public boolean isCalled()
+    {
+        return called;
+    }
+}


Mime
View raw message