You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by GitBox <gi...@apache.org> on 2020/11/09 14:58:19 UTC

[GitHub] [isis] joerg-rade opened a new pull request #274: Isis 2454

joerg-rade opened a new pull request #274:
URL: https://github.com/apache/isis/pull/274


   Please review CorsFilterTest: 
   * How can the CORS filter added to the filter chain? 
   * Is there a way to have uid/pw checked? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [isis] andi-huber merged pull request #274: Isis 2454

Posted by GitBox <gi...@apache.org>.
andi-huber merged pull request #274:
URL: https://github.com/apache/isis/pull/274


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [isis] danhaywood commented on a change in pull request #274: Isis 2454

Posted by GitBox <gi...@apache.org>.
danhaywood commented on a change in pull request #274:
URL: https://github.com/apache/isis/pull/274#discussion_r520043172



##########
File path: regressiontests/stable/src/test/java/org/apache/isis/testdomain/rest/CorsFilterTest.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.isis.testdomain.rest;
+
+import org.apache.isis.extensions.cors.impl.IsisModuleExtCorsImpl;
+import org.apache.isis.testdomain.conf.Configuration_headlessButSecure;
+import org.apache.isis.testdomain.rospec.Configuration_usingRoSpec;
+import org.apache.isis.testdomain.util.rest.RestEndpointService;
+import org.apache.isis.viewer.restfulobjects.jaxrsresteasy4.IsisModuleViewerRestfulObjectsJaxrsResteasy4;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@ActiveProfiles("test")
+@RunWith(SpringRunner.class)
+@SpringBootTest(
+        classes = RestEndpointService.class,
+        properties = {
+//                "sven = pass, admin_role",

Review comment:
       should these be removed if they are commented out?  Or perhaps a more useful comment if their absence is notable?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [isis] danhaywood commented on a change in pull request #274: Isis 2454

Posted by GitBox <gi...@apache.org>.
danhaywood commented on a change in pull request #274:
URL: https://github.com/apache/isis/pull/274#discussion_r520042866



##########
File path: regressiontests/stable/src/test/java/org/apache/isis/testdomain/rest/CorsFilterTest.java
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.isis.testdomain.rest;
+
+import org.apache.isis.extensions.cors.impl.IsisModuleExtCorsImpl;
+import org.apache.isis.testdomain.conf.Configuration_headlessButSecure;
+import org.apache.isis.testdomain.rospec.Configuration_usingRoSpec;
+import org.apache.isis.testdomain.util.rest.RestEndpointService;
+import org.apache.isis.viewer.restfulobjects.jaxrsresteasy4.IsisModuleViewerRestfulObjectsJaxrsResteasy4;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.context.annotation.Import;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@ActiveProfiles("test")
+@RunWith(SpringRunner.class)
+@SpringBootTest(
+        classes = RestEndpointService.class,
+        properties = {
+//                "sven = pass, admin_role",
+//                "admin_role = *"
+        },
+        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@Import({
+        IsisModuleExtCorsImpl.class,
+        Configuration_headlessButSecure.class,
+        Configuration_usingRoSpec.class,
+        IsisModuleViewerRestfulObjectsJaxrsResteasy4.class,
+})
+class CorsFilterTest {
+
+    @LocalServerPort
+    private int port;
+
+    @Test
+    public void ensureCorsFilterIsInChain() {

Review comment:
       I don't see how the test body relates to the test name.
   
   Also, could you add //given, //when, //then comments/regions, so that it's clear which is the main behaviour being exercised (in the //when) ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [isis] andi-huber commented on a change in pull request #274: Isis 2454

Posted by GitBox <gi...@apache.org>.
andi-huber commented on a change in pull request #274:
URL: https://github.com/apache/isis/pull/274#discussion_r521174107



##########
File path: regressiontests/stable/src/main/java/org/apache/isis/testdomain/conf/Configuration_headlessButSecure.java
##########
@@ -0,0 +1,153 @@
+/*
+ *  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.isis.testdomain.conf;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import lombok.RequiredArgsConstructor;
+import lombok.val;
+import org.apache.isis.applib.annotation.OrderPrecedence;
+import org.apache.isis.applib.services.command.Command;
+import org.apache.isis.applib.services.iactn.Interaction;
+import org.apache.isis.applib.services.iactn.InteractionContext;
+import org.apache.isis.applib.services.metrics.MetricsService;
+import org.apache.isis.commons.internal.debug._Probe;
+import org.apache.isis.core.metamodel.services.command.CommandServiceInternal;
+import org.apache.isis.core.runtime.events.iactn.IsisInteractionLifecycleEvent;
+import org.apache.isis.extensions.cors.impl.IsisModuleExtCorsImpl;
+import org.apache.isis.extensions.modelannotation.metamodel.IsisModuleExtModelAnnotation;
+import org.apache.isis.security.bypass.IsisModuleSecurityBypass;
+import org.springframework.context.annotation.*;
+
+import org.apache.isis.core.runtimeservices.IsisModuleCoreRuntimeServices;
+import org.apache.isis.extensions.secman.api.SecurityModuleConfig;
+import org.apache.isis.extensions.secman.api.permission.PermissionsEvaluationService;
+import org.apache.isis.extensions.secman.api.permission.PermissionsEvaluationServiceAllowBeatsVeto;
+import org.apache.isis.testdomain.util.kv.KVStoreForTesting;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionException;
+import org.springframework.transaction.TransactionStatus;
+
+import java.util.Optional;
+
+@Configuration
+@Import({
+        IsisModuleCoreRuntimeServices.class,
+        //IsisModuleCoreSecurity.class,
+        IsisModuleSecurityBypass.class,
+        IsisModuleExtModelAnnotation.class, // @Model support
+        IsisModuleExtCorsImpl.class,
+        Configuration_headlessButSecure.HeadlessCommandSupport.class,
+        KVStoreForTesting.class, // Helper for JUnit Tests
+})
+public class Configuration_headlessButSecure {

Review comment:
       Do we need to introduce this code duplication here with respect to the existing `Configuration_headless` class? If something is preventing us from reusing `Configuration_headless`, I'd rather see `Configuration_headless` changed/fixed such that we can avoid code duplication. (This might sound picky, but its easy to add lines of code, and hard to get rid of lines of code.)

##########
File path: extensions/vro/cors/impl/pom.xml
##########
@@ -46,6 +46,31 @@
 		    <artifactId>spring-web</artifactId>
 		</dependency>
 
+        <!-- TESTS -->
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>isis-core-internaltestsupport</artifactId>
+            <scope>test</scope>
+            <!-- provided by Spring Boot -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.tomcat.embed</groupId>
+			<artifactId>tomcat-embed-core</artifactId>
+			<version>9.0.37</version>
+			<scope>test</scope>
+		</dependency>
+

Review comment:
       Might be opinionated, but lets rather not bring in this heavy lifting test infrastructure into these tiny extension modules. That's what the regressiontests module is for.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org