chibenwa commented on a change in pull request #781:
URL: https://github.com/apache/james-project/pull/781#discussion_r765823589



##########
File path: 
server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/rfc8621/RFC8621MethodsModule.java
##########
@@ -108,6 +108,10 @@
 
 public class RFC8621MethodsModule extends AbstractModule {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(RFC8621MethodsModule.class);
+    public static PackageName IMPLICIT_AUTHENTICATION_STRATEGY_FQDN_PREFIX = 
PackageName.of("org.apache.james.jmap.http");
+    public static List<String> DEFAULT_AUTHENTICATION_STRATEGIES = 
ImmutableList.of(

Review comment:
       idem?

##########
File path: 
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/custom/authentication/strategy/ModularizeJmapRFC8621AuthenticationStrategyContract.java
##########
@@ -41,58 +41,29 @@
 import static org.hamcrest.Matchers.equalTo;
 import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.ACCEPT;
 
-import java.io.IOException;
+import java.util.List;
 import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.draft.JmapGuiceProbe;
-import org.apache.james.jmap.http.AuthenticationStrategy;
-import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.utils.DataProbeImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 import io.restassured.RestAssured;
 import io.restassured.http.Header;
 
 public abstract class ModularizeJmapRFC8621AuthenticationStrategyContract {
-    private AllowAuthenticationStrategy allowAuthenticationStrategy;
-    private DenyAuthenticationStrategy denyAuthenticationStrategy;
-    private GuiceJamesServer jmapServer;
-
-    protected abstract GuiceJamesServer 
createJmapServerWithAllowAuthenticationStrategy(AllowAuthenticationStrategy 
authenticationStrategy) throws IOException;
-
-    protected abstract GuiceJamesServer 
createJmapServerWithDenyAuthenticationStrategy(DenyAuthenticationStrategy 
authenticationStrategy) throws IOException;
+    public static Optional<List<String>> ALLOW_AUTHENTICATION_STRATEGY = 
Optional.of(List.of(AllowAuthenticationStrategy.class.getCanonicalName()));
+    public static Optional<List<String>> DENY_AUTHENTICATION_STRATEGY = 
Optional.of(List.of(DenyAuthenticationStrategy.class.getCanonicalName()));
+    public static Optional<List<String>> DEFAULT_STRATEGIES = Optional.empty();
 
-    protected abstract GuiceJamesServer 
createJmapServerWithDefaultAuthenticationStrategies() throws IOException;
-
-    protected abstract MailboxManager initMailboxManager();
+    private GuiceJamesServer jmapServer;
 
-    @Before
-    public void setup() {
-        MailboxManager mailboxManager = initMailboxManager();
-        allowAuthenticationStrategy = new 
AllowAuthenticationStrategy(mailboxManager);
-        denyAuthenticationStrategy = new DenyAuthenticationStrategy();
-    }
+    protected abstract GuiceJamesServer createJmapServer(GuiceJamesServer 
basedServer, Optional<List<String>> authOverride);

Review comment:
       I bet the logic in this method is the same for both implementations and 
thus don't  need to be implemented by both implementations...

##########
File path: 
server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryModularizeJmapRFC8621AuthenticationStrategyContract.java
##########
@@ -19,47 +19,32 @@
 
 package org.apache.james.jmap.rfc8621.memory;
 
-import java.io.IOException;
 import java.util.List;
+import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.jmap.core.JmapRfc8621Configuration;
-import 
org.apache.james.jmap.rfc8621.contract.custom.authentication.strategy.AllowAuthenticationStrategy;
-import 
org.apache.james.jmap.rfc8621.contract.custom.authentication.strategy.DenyAuthenticationStrategy;
 import 
org.apache.james.jmap.rfc8621.contract.custom.authentication.strategy.ModularizeJmapRFC8621AuthenticationStrategyContract;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
-import org.junit.Rule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 public class MemoryModularizeJmapRFC8621AuthenticationStrategyContract extends 
ModularizeJmapRFC8621AuthenticationStrategyContract {
-    @Rule
-    public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
+    @RegisterExtension
+    static JamesServerExtension testExtension = new 
JamesServerBuilder<>(JamesServerBuilder.defaultConfigurationProvider())
+        .server(configuration -> 
MemoryJamesServerMain.createServer(configuration)
+            .overrideWith(new TestJMAPServerModule()))
+        .disableAutoStart()
+        .build();
 
     @Override
-    protected GuiceJamesServer 
createJmapServerWithAllowAuthenticationStrategy(AllowAuthenticationStrategy 
authenticationStrategy) throws IOException {
-        return memoryJmap.jmapServer()
+    protected GuiceJamesServer createJmapServer(GuiceJamesServer basedServer, 
Optional<List<String>> authOverride) {
+        return basedServer
             .overrideWith(binder -> binder.bind(JmapRfc8621Configuration.class)
                 .toInstance(JmapRfc8621Configuration.LOCALHOST_CONFIGURATION()
-                        
.withAuthenticationStrategies(List.of(AllowAuthenticationStrategy.class.getCanonicalName()))))
-            .overrideWith(binder -> 
binder.bind(AllowAuthenticationStrategy.class).toInstance(authenticationStrategy));
+                    .withAuthenticationStrategies(authOverride.orElse(null))));

Review comment:
       Bongo, nothing related to memory :-)

##########
File path: 
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/custom/authentication/strategy/ModularizeJmapRFC8621AuthenticationStrategyContract.java
##########
@@ -41,58 +41,29 @@
 import static org.hamcrest.Matchers.equalTo;
 import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.ACCEPT;
 
-import java.io.IOException;
+import java.util.List;
 import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.draft.JmapGuiceProbe;
-import org.apache.james.jmap.http.AuthenticationStrategy;
-import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.utils.DataProbeImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 
 import io.restassured.RestAssured;
 import io.restassured.http.Header;
 
 public abstract class ModularizeJmapRFC8621AuthenticationStrategyContract {
-    private AllowAuthenticationStrategy allowAuthenticationStrategy;
-    private DenyAuthenticationStrategy denyAuthenticationStrategy;
-    private GuiceJamesServer jmapServer;
-
-    protected abstract GuiceJamesServer 
createJmapServerWithAllowAuthenticationStrategy(AllowAuthenticationStrategy 
authenticationStrategy) throws IOException;
-
-    protected abstract GuiceJamesServer 
createJmapServerWithDenyAuthenticationStrategy(DenyAuthenticationStrategy 
authenticationStrategy) throws IOException;
+    public static Optional<List<String>> ALLOW_AUTHENTICATION_STRATEGY = 
Optional.of(List.of(AllowAuthenticationStrategy.class.getCanonicalName()));
+    public static Optional<List<String>> DENY_AUTHENTICATION_STRATEGY = 
Optional.of(List.of(DenyAuthenticationStrategy.class.getCanonicalName()));
+    public static Optional<List<String>> DEFAULT_STRATEGIES = Optional.empty();
 
-    protected abstract GuiceJamesServer 
createJmapServerWithDefaultAuthenticationStrategies() throws IOException;
-
-    protected abstract MailboxManager initMailboxManager();
+    private GuiceJamesServer jmapServer;
 
-    @Before
-    public void setup() {
-        MailboxManager mailboxManager = initMailboxManager();
-        allowAuthenticationStrategy = new 
AllowAuthenticationStrategy(mailboxManager);
-        denyAuthenticationStrategy = new DenyAuthenticationStrategy();
-    }
+    protected abstract GuiceJamesServer createJmapServer(GuiceJamesServer 
basedServer, Optional<List<String>> authOverride);
 
-    public void 
setupJamesServerWithCustomAuthenticationStrategy(Optional<AuthenticationStrategy>
 authenticationStrategy) throws Throwable {
-        jmapServer = authenticationStrategy.map(strategy -> {
-            if (strategy instanceof AllowAuthenticationStrategy) {
-                try {
-                    return 
createJmapServerWithAllowAuthenticationStrategy((AllowAuthenticationStrategy) 
strategy);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            } else if (strategy instanceof DenyAuthenticationStrategy) {
-                try {
-                    return 
createJmapServerWithDenyAuthenticationStrategy((DenyAuthenticationStrategy) 
strategy);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            return null;
-        }).orElse(createJmapServerWithDefaultAuthenticationStrategies());
+    public void 
setupJamesServerWithCustomAuthenticationStrategy(GuiceJamesServer basedServer, 
Optional<List<String>> authOverride) throws Throwable {
+        jmapServer = createJmapServer(basedServer, authOverride);

Review comment:
       Why create a new server if we already have one?

##########
File path: 
server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/draft/DraftMethodsModule.java
##########
@@ -72,6 +72,10 @@
 import com.google.inject.name.Names;
 
 public class DraftMethodsModule extends AbstractModule {
+    public static PackageName IMPLICIT_AUTHENTICATION_STRATEGY_FQDN_PREFIX = 
PackageName.of("org.apache.james.jmap.http");
+    public static List<String> DEFAULT_AUTHENTICATION_STRATEGIES = 
ImmutableList.of(AccessTokenAuthenticationStrategy.class.getSimpleName(),

Review comment:
       private ?




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to