[
https://issues.apache.org/jira/browse/GEODE-3117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16065365#comment-16065365
]
ASF GitHub Bot commented on GEODE-3117:
---------------------------------------
Github user pdxrunner commented on a diff in the pull request:
https://github.com/apache/geode/pull/601#discussion_r124376469
--- Diff:
geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/GatewayLegacyAuthenticationRegressionTest.java
---
@@ -0,0 +1,429 @@
+/*
+ * 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.geode.internal.cache.wan.misc;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static
org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID;
+import static
org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static
org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static
org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS;
+import static
org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
+import static
org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
+import static
org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT;
+import static
org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.awaitility.Awaitility.waitAtMost;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.LogWriter;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.DiskStore;
+import org.apache.geode.cache.DiskStoreFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.wan.GatewayReceiver;
+import org.apache.geode.cache.wan.GatewayReceiverFactory;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.cache.wan.GatewaySenderFactory;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory;
+import org.apache.geode.security.AuthInitialize;
+import org.apache.geode.security.AuthenticationFailedException;
+import org.apache.geode.security.Authenticator;
+import org.apache.geode.test.dunit.DistributedTestCase;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.apache.geode.test.junit.categories.WanTest;
+import
org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
+
+/**
+ * Reproduces bug GEODE-3117: "Gateway authentication throws
NullPointerException" and validates the
+ * fix.
+ */
+@Category({DistributedTest.class, SecurityTest.class, WanTest.class})
+public class GatewayLegacyAuthenticationRegressionTest extends
DistributedTestCase {
+
+ private static final String USER_NAME = "security-username";
+ private static final String PASSWORD = "security-password";
+
+ private static final AtomicInteger invokeAuthenticateCount = new
AtomicInteger();
+
+ private static Cache cache;
+ private static GatewaySender sender;
+
+ private VM londonLocatorVM;
+ private VM newYorkLocatorVM;
+ private VM londonServerVM;
+ private VM newYorkServerVM;
+
+ private String londonName;
+ private String newYorkName;
+
+ private int londonId;
+ private int newYorkId;
+
+ private int londonLocatorPort;
+ private int newYorkLocatorPort;
+
+ private String regionName;
+
+ @Rule
+ public SerializableTemporaryFolder temporaryFolder = new
SerializableTemporaryFolder();
+
+ @Before
+ public void before() {
+ invokeAuthenticateCount.set(0);
+
+ this.londonLocatorVM = getHost(0).getVM(0);
+ this.newYorkLocatorVM = getHost(0).getVM(1);
+ this.londonServerVM = getHost(0).getVM(2);
+ this.newYorkServerVM = getHost(0).getVM(3);
+
+ this.londonName = "ln";
+ this.newYorkName = "ny";
+
+ this.londonId = 1;
+ this.newYorkId = 2;
+
+ this.regionName = getTestMethodName() + "_RR";
+
+ int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+ this.londonLocatorPort = ports[0];
+ this.newYorkLocatorPort = ports[1];
+ }
+
+ /**
+ * Use of SECURITY_CLIENT_AUTHENTICATOR should result in the servers
performing authentication
+ * during HandShake of Gateway Sender/Receiver connecting.
+ */
+ @Test
+ public void gatewayHandShakeShouldAuthenticate() {
+ this.londonLocatorVM.invoke("start London locator", () -> {
+ getSystem(
+ createLocatorConfig(this.londonId, this.londonLocatorPort,
this.newYorkLocatorPort));
+ });
+
+ this.newYorkLocatorVM.invoke("start New York locator", () -> {
+ getSystem(
+ createLocatorConfig(this.newYorkId, this.newYorkLocatorPort,
this.londonLocatorPort));
+ });
+
+ this.londonServerVM.invoke("create London server", () -> {
+ startServer(this.londonId, this.londonLocatorPort, this.newYorkId,
this.newYorkName);
+ });
+
+ this.newYorkServerVM.invoke("create New York server", () -> {
+ startServer(this.newYorkId, this.newYorkLocatorPort, this.londonId,
this.londonName);
+ });
+
+ this.londonServerVM.invoke(() -> {
+ await().atMost(1, MINUTES).until(() ->
assertThat(isRunning(sender)).isTrue());
+ });
+
+ this.newYorkServerVM.invoke(() -> {
+ await().atMost(1, MINUTES).until(() ->
assertThat(isRunning(sender)).isTrue());
+ });
+
+ this.newYorkServerVM.invoke(() -> {
+ // assertThat(invokeAuthenticateCount).isEqualTo(1);
+ });
+
+ this.londonServerVM.invoke(() -> {
+ // assertThat(invokeAuthenticateCount).isEqualTo(1);
+ });
--- End diff --
You're invoking null methods on the servers?
> Gateway authentication throws NullPointerException
> --------------------------------------------------
>
> Key: GEODE-3117
> URL: https://issues.apache.org/jira/browse/GEODE-3117
> Project: Geode
> Issue Type: Bug
> Components: security, wan
> Reporter: Kirk Lund
> Assignee: Kirk Lund
> Attachments: geode-3117.tar
>
>
> {noformat}
> java.lang.NullPointerException
> at
> org.apache.geode.security.templates.DummyAuthenticator.authenticate(DummyAuthenticator.java:50)
> at
> org.apache.geode.internal.cache.tier.sockets.HandShake.verifyCredentials(HandShake.java:1699)
> at
> org.apache.geode.internal.cache.tier.sockets.HandShake.checkIfAuthenticWanSite(HandShake.java:1746)
> at
> org.apache.geode.internal.cache.tier.sockets.HandShake.readMessage(HandShake.java:1409)
> at
> org.apache.geode.internal.cache.tier.sockets.HandShake.handshakeWithServer(HandShake.java:1258)
> at
> org.apache.geode.cache.client.internal.ConnectionImpl.connect(ConnectionImpl.java:117)
> at
> org.apache.geode.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:136)
> at
> org.apache.geode.cache.client.internal.ConnectionFactoryImpl.createClientToServerConnection(ConnectionFactoryImpl.java:259)
> at
> org.apache.geode.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:206)
> at
> org.apache.geode.cache.client.internal.PoolImpl.acquireConnection(PoolImpl.java:898)
> at
> org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher.initializeConnection(GatewaySenderEventRemoteDispatcher.java:402)
> at
> org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher.getConnection(GatewaySenderEventRemoteDispatcher.java:317)
> at
> org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher._dispatchBatch(GatewaySenderEventRemoteDispatcher.java:199)
> at
> org.apache.geode.internal.cache.wan.GatewaySenderEventRemoteDispatcher.dispatchBatch(GatewaySenderEventRemoteDispatcher.java:148)
> at
> org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor.processQueue(AbstractGatewaySenderEventProcessor.java:609)
> at
> org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderEventProcessor.run(SerialGatewaySenderEventProcessor.java:223)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)