Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1CD22200CB4 for ; Tue, 27 Jun 2017 21:46:32 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1B0FA160BDC; Tue, 27 Jun 2017 19:46:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6183F160BD8 for ; Tue, 27 Jun 2017 21:46:31 +0200 (CEST) Received: (qmail 68098 invoked by uid 500); 27 Jun 2017 19:46:25 -0000 Mailing-List: contact dev-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list dev@geode.apache.org Received: (qmail 68087 invoked by uid 99); 27 Jun 2017 19:46:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Jun 2017 19:46:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 70C9ADFA6C; Tue, 27 Jun 2017 19:46:23 +0000 (UTC) From: pdxrunner To: dev@geode.apache.org Reply-To: dev@geode.apache.org References: In-Reply-To: Subject: [GitHub] geode pull request #601: GEODE-3117: fix Gateway authentication with legacy ... Content-Type: text/plain Message-Id: <20170627194624.70C9ADFA6C@git1-us-west.apache.org> Date: Tue, 27 Jun 2017 19:46:23 +0000 (UTC) archived-at: Tue, 27 Jun 2017 19:46:32 -0000 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? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---