You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ec...@apache.org on 2017/03/23 20:45:02 UTC
geode-native git commit: GEODE-2687: Ensure three tests for SSL
authentication.
Repository: geode-native
Updated Branches:
refs/heads/develop 456de2a24 -> 8b67c1306
GEODE-2687: Ensure three tests for SSL authentication.
- Remove unnecessary header file by merging its code
into the source file.
- Ensure failure in the absence of the expected
exception in testThinClientSSLAuthFail.
- Add testThinClientSSLAuthCorrupt for a corrupted
client keystore.
- Add testThinClientSSLAuthUntrusted for an untrusted
client keystore.
Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/8b67c130
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/8b67c130
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/8b67c130
Branch: refs/heads/develop
Commit: 8b67c1306c71148b74c95ac6e813c21dfaba2b9e
Parents: 456de2a
Author: Sarge <md...@pivotal.io>
Authored: Wed Mar 22 12:28:53 2017 -0700
Committer: Ernest Burghardt <eb...@pivotal.io>
Committed: Thu Mar 23 13:44:39 2017 -0700
----------------------------------------------------------------------
src/cppcache/integration-test/CMakeLists.txt | 2 +
.../integration-test/ThinClientSSLAuthFail.hpp | 198 -------------------
.../keystore/client_keystore_corrupt.pem | 45 +++++
.../keystore/client_keystore_untrusted.pem | 30 +++
.../testThinClientSSLAuthCorrupt.cpp | 194 ++++++++++++++++++
.../testThinClientSSLAuthFail.cpp | 176 ++++++++++++++++-
.../testThinClientSSLAuthUntrusted.cpp | 195 ++++++++++++++++++
7 files changed, 640 insertions(+), 200 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/CMakeLists.txt b/src/cppcache/integration-test/CMakeLists.txt
index 8f7824e..71ee174 100644
--- a/src/cppcache/integration-test/CMakeLists.txt
+++ b/src/cppcache/integration-test/CMakeLists.txt
@@ -134,6 +134,8 @@ set_property(TEST testAttributesMutator PROPERTY LABELS STABLE QUICK)
set_property(TEST testEntriesMapForVersioning PROPERTY LABELS STABLE QUICK)
set_property(TEST testSpinLock PROPERTY LABELS STABLE QUICK)
set_property(TEST testThinClientSSLAuthFail PROPERTY LABELS STABLE QUICK)
+set_property(TEST testThinClientSSLAuthCorrupt PROPERTY LABELS STABLE QUICK)
+set_property(TEST testThinClientSSLAuthUntrusted PROPERTY LABELS STABLE QUICK)
set_property(TEST testOverflowPutGetSqLite PROPERTY LABELS FLAKY)
set_property(TEST testThinClientAfterRegionLive PROPERTY LABELS FLAKY)
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/ThinClientSSLAuthFail.hpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/ThinClientSSLAuthFail.hpp b/src/cppcache/integration-test/ThinClientSSLAuthFail.hpp
deleted file mode 100644
index de226c0..0000000
--- a/src/cppcache/integration-test/ThinClientSSLAuthFail.hpp
+++ /dev/null
@@ -1,198 +0,0 @@
-#pragma once
-
-#ifndef GEODE_INTEGRATION_TEST_THINCLIENTSSL_H_
-#define GEODE_INTEGRATION_TEST_THINCLIENTSSL_H_
-
-/*
- * 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.
- */
-
-#include "fw_dunit.hpp"
-#include <geode/GeodeCppCache.hpp>
-#include <ace/OS.h>
-#include <ace/High_Res_Timer.h>
-#include <string>
-
-#define ROOT_NAME "ThinClientSSLAuthFail"
-#define ROOT_SCOPE DISTRIBUTED_ACK
-
-#include "CacheHelper.hpp"
-
-using namespace apache::geode::client;
-using namespace test;
-
-CacheHelper* cacheHelper = NULL;
-bool isLocalServer = false;
-
-static bool isLocator = false;
-const char* locatorsG =
- CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
-
-#define CLIENT1 s1p1
-#define SERVER1 s2p1
-
-void initClient(const bool isthinClient) {
- if (cacheHelper == NULL) {
- PropertiesPtr props = Properties::create();
- props->insert("ssl-enabled", "true");
- std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
- std::string pubkey = keystore + "/client_truststore.pem";
- std::string privkey = keystore + "/client_keystore.pem";
- props->insert("ssl-keystore", privkey.c_str());
- props->insert("ssl-truststore", pubkey.c_str());
- cacheHelper = new CacheHelper(isthinClient, props);
- }
- ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
-}
-void cleanProc() {
- if (cacheHelper != NULL) {
- delete cacheHelper;
- cacheHelper = NULL;
- }
-}
-
-CacheHelper* getHelper() {
- ASSERT(cacheHelper != NULL, "No cacheHelper initialized.");
- return cacheHelper;
-}
-
-
-void createPooledRegion(const char* name, bool ackMode, const char* locators,
- const char* poolname,
- bool clientNotificationEnabled = false,
- bool cachingEnable = true) {
- LOG("createRegion_Pool() entered.");
- fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
- fflush(stdout);
- RegionPtr regPtr =
- getHelper()->createPooledRegion(name, ackMode, locators, poolname,
- cachingEnable, clientNotificationEnabled);
- ASSERT(regPtr != NULLPTR, "Failed to create region.");
- LOG("Pooled Region created.");
-}
-
-void createEntry(const char* name, const char* key, const char* value) {
- LOG("createEntry() entered.");
- fprintf(stdout, "Creating entry -- key: %s value: %s in region %s\n", key,
- value, name);
- fflush(stdout);
- // Create entry, verify entry is correct
- CacheableKeyPtr keyPtr = createKey(key);
- CacheableStringPtr valPtr = CacheableString::create(value);
-
- RegionPtr regPtr = getHelper()->getRegion(name);
- ASSERT(regPtr != NULLPTR, "Region not found.");
-
- ASSERT(!regPtr->containsKey(keyPtr),
- "Key should not have been found in region.");
- ASSERT(!regPtr->containsValueForKey(keyPtr),
- "Value should not have been found in region.");
-
- // regPtr->create( keyPtr, valPtr );
- regPtr->put(keyPtr, valPtr);
- LOG("Created entry.");
-
- //verifyEntry(name, key, value);
- LOG("Entry created.");
-}
-
-
-
-const char* keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
-const char* vals[] = {"Value-1", "Value-2", "Value-3", "Value-4"};
-const char* nvals[] = {"New Value-1", "New Value-2", "New Value-3",
- "New Value-4"};
-
-const char* regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
-
-const bool USE_ACK = true;
-const bool NO_ACK = false;
-
-DUNIT_TASK_DEFINITION(SERVER1, CreateLocator1_With_SSL_untrustedCert)
- {
- // starting locator
- if (isLocator) CacheHelper::initLocator(1, true, false, -1, 0, true);
- LOG("Locator1 started with SSL");
- }
-END_TASK_DEFINITION
-
-
-
-DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
- {
- // starting servers
- if (isLocalServer) CacheHelper::initServer(1, NULL, locatorsG, NULL, true, true, false, false, true);
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
- { initClient(true); }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, CreateRegions1_PoolLocators)
- {
- createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
- true);
- createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true);
- RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
- try {
- regPtr->registerAllKeys(false, NULLPTR, false, false);
- }
- catch (NotConnectedException exp) {
- LOG("Connection Failed as expected via NotConnectedException");
- }
- LOG("CreateRegions1_PoolLocators complete.");
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
- { cleanProc(); }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
- {
- if (isLocalServer) {
- CacheHelper::closeServer(1);
- LOG("SERVER1 stopped");
- }
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(SERVER1, CloseLocator_With_SSL)
- {
- // stop locator
- if (isLocator) {
- CacheHelper::closeLocator(1, true);
- LOG("Locator1 stopped");
- }
- }
-END_TASK_DEFINITION
-
-void doThinClientSSL(bool poolConfig = true, bool poolLocators = true) {
- CALL_TASK(CreateLocator1_With_SSL_untrustedCert);
- CALL_TASK(CreateServer1_With_Locator_And_SSL_untrustedCert)
-
- CALL_TASK(CreateClient1);
-
- CALL_TASK(CreateRegions1_PoolLocators);
-
- CALL_TASK(CloseCache1);
- CALL_TASK(CloseServer1);
-
- CALL_TASK(CloseLocator_With_SSL);
-}
-
-#endif // GEODE_INTEGRATION_TEST_THINCLIENTSSL_H_
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/keystore/client_keystore_corrupt.pem
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/keystore/client_keystore_corrupt.pem b/src/cppcache/integration-test/keystore/client_keystore_corrupt.pem
new file mode 100755
index 0000000..e41f773
--- /dev/null
+++ b/src/cppcache/integration-test/keystore/client_keystore_corrupt.pem
@@ -0,0 +1,45 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAp285nn8EDUa2fRmYGrNOUFtkk2sCeMh8fthTsp0AOpBKnCLr
+jVMgXsnivO5/RtEOdM+KqhOp6HaTR4dnWlW8aNeIDydmdFjK/gsBpJKyfQw/7QW7
+OVHeHbLbPr6/zazy+1Zpkx5HBOSYrnqV1KyVfo+M+Y7l2TJC5/i3CVL+d5a+bqjs
+UpXrZWcN6Vgu5VRNJ/hk8jB/UHjA9FUbmreUSL1TqoItUHniPcAATp+m2zx9goMC
+A2CzWV5vece9QI3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MGrZFjnZ3TNRChwQY8P5GlDvyj5oLJ6VZFMAaidWvFrR5oDLm8Khkq
+2vLQXnnchje9hm6jDxaO58XsfU5zicfYRuXi2vYmOgltyCixBWQvEwbI+Uf7F6Lw
+Da7bpNwTgiYs3snB83trYe17hlUaiF7MNC6lCVdy1/F7FbN/ToQQIDpxHVx7jm6n
+SrOtPnOMLoXB9Gcfrtidu1k/ZFyySskK/HnYc1bfGJ9+B1GzbVahuzr/Jdfp62sE
+XxEVh9pXSb0gkB/CUpTEx7ve9jU8tEYNUqMDUj87Qg==
+-----END CERTIFICATE-----
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/keystore/client_keystore_untrusted.pem
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/keystore/client_keystore_untrusted.pem b/src/cppcache/integration-test/keystore/client_keystore_untrusted.pem
new file mode 100755
index 0000000..b316d7b
--- /dev/null
+++ b/src/cppcache/integration-test/keystore/client_keystore_untrusted.pem
@@ -0,0 +1,30 @@
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: AES-256-CBC,1D33EB50F0D52CAE9CB64EFBA17481E8
+
+Kh7gfmoqXOjwAjtshMs/nuPvsPJ1ihDbgebHHxvyh40tLQ1dNbR27gtzdxD98mbd
+6a+NrqrnB4+ki4z4TaUYUzZd2Z+p0jhUWTj1hrvOdydsUvSZ2oDAaiVZRUo38b52
+o6N1TY66TfSzAu9karcQnrDaQhLlBucjbHuBYuL9q7Mkf67S7ZoHd0vZ7f8tgxD8
+jGCPjEhA6yY9HcmgqcadICi0CyvKpxQvZ6+YLl8W0iIooou+FFDtfdqThwLETvE5
+fZVow7feAcUoKdglXopfKlKV72zU+AehgDKcAYHOlNnpm6awOHu73brlZc+D9A54
+MI4NkWE4wg8C6IWX+JJwZT8yvT3SIqMHW68Ie/owObPAm68o1zTwFdN4EL/2NqMO
+ktohvhpAa0cniv+bB6OD3xfQLcEYRtZGZ71wZ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eKImj7+roGKQjFoy/fFb4kQg1guz+vuXkCv1iovDY/5M4316X8eYF6GMHjEGKvgM
+ThE+Y2kC8GEDzBWYKrJJ5P6xg+t5qcimSAQrS94bG+E8ntuYcOscZaRLwEgoOaEV
+-----END RSA PRIVATE KEY-----
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp b/src/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
new file mode 100644
index 0000000..3920f6f
--- /dev/null
+++ b/src/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
@@ -0,0 +1,194 @@
+/*
+ * 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.
+ */
+
+#include "fw_dunit.hpp"
+#include <geode/GeodeCppCache.hpp>
+#include <ace/OS.h>
+#include <ace/High_Res_Timer.h>
+#include <string>
+
+#define ROOT_NAME "ThinClientSSLAuthCorrupt"
+#define ROOT_SCOPE DISTRIBUTED_ACK
+
+#include "CacheHelper.hpp"
+
+using namespace apache::geode::client;
+using namespace test;
+
+CacheHelper* cacheHelper = NULL;
+bool isLocalServer = false;
+
+static bool isLocator = false;
+const char* locatorsG =
+ CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
+
+#define CLIENT1 s1p1
+#define SERVER1 s2p1
+
+void initClient(const bool isthinClient) {
+ if (cacheHelper == NULL) {
+ PropertiesPtr props = Properties::create();
+ props->insert("ssl-enabled", "true");
+ std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
+ std::string pubkey = keystore + "/client_truststore.pem";
+ std::string privkey = keystore + "/client_keystore_corrupt.pem";
+ props->insert("ssl-keystore", privkey.c_str());
+ props->insert("ssl-truststore", pubkey.c_str());
+ cacheHelper = new CacheHelper(isthinClient, props);
+ }
+ ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+}
+void cleanProc() {
+ if (cacheHelper != NULL) {
+ delete cacheHelper;
+ cacheHelper = NULL;
+ }
+}
+
+CacheHelper* getHelper() {
+ ASSERT(cacheHelper != NULL, "No cacheHelper initialized.");
+ return cacheHelper;
+}
+
+
+void createPooledRegion(const char* name, bool ackMode, const char* locators,
+ const char* poolname,
+ bool clientNotificationEnabled = false,
+ bool cachingEnable = true) {
+ LOG("createRegion_Pool() entered.");
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fflush(stdout);
+ RegionPtr regPtr =
+ getHelper()->createPooledRegion(name, ackMode, locators, poolname,
+ cachingEnable, clientNotificationEnabled);
+ ASSERT(regPtr != NULLPTR, "Failed to create region.");
+ LOG("Pooled Region created.");
+}
+
+void createEntry(const char* name, const char* key, const char* value) {
+ LOG("createEntry() entered.");
+ fprintf(stdout, "Creating entry -- key: %s value: %s in region %s\n", key,
+ value, name);
+ fflush(stdout);
+ // Create entry, verify entry is correct
+ CacheableKeyPtr keyPtr = createKey(key);
+ CacheableStringPtr valPtr = CacheableString::create(value);
+
+ RegionPtr regPtr = getHelper()->getRegion(name);
+ ASSERT(regPtr != NULLPTR, "Region not found.");
+
+ ASSERT(!regPtr->containsKey(keyPtr),
+ "Key should not have been found in region.");
+ ASSERT(!regPtr->containsValueForKey(keyPtr),
+ "Value should not have been found in region.");
+
+ // regPtr->create( keyPtr, valPtr );
+ regPtr->put(keyPtr, valPtr);
+ LOG("Created entry.");
+
+ //verifyEntry(name, key, value);
+ LOG("Entry created.");
+}
+
+
+
+const char* keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
+const char* vals[] = {"Value-1", "Value-2", "Value-3", "Value-4"};
+const char* nvals[] = {"New Value-1", "New Value-2", "New Value-3",
+ "New Value-4"};
+
+const char* regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
+
+const bool USE_ACK = true;
+const bool NO_ACK = false;
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateLocator1_With_SSL_untrustedCert)
+ {
+ // starting locator
+ if (isLocator) CacheHelper::initLocator(1, true, false, -1, 0, false);
+ LOG("Locator1 started with SSL");
+ }
+END_TASK_DEFINITION
+
+
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
+ {
+ // starting servers
+ if (isLocalServer) CacheHelper::initServer(1, NULL, locatorsG, NULL, true, true, false, false, false);
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
+ { initClient(true); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateRegions1_PoolLocators)
+ {
+ createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
+ true);
+ createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true);
+ RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
+ try {
+ regPtr->registerAllKeys(false, NULLPTR, false, false);
+ FAIL("Should have got NotConnectedException during registerAllKeys");
+ }
+ catch (NotConnectedException exp) {
+ LOG("Connection Failed as expected via NotConnectedException");
+ }
+ LOG("CreateRegions1_PoolLocators complete.");
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
+ { cleanProc(); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
+ {
+ if (isLocalServer) {
+ CacheHelper::closeServer(1);
+ LOG("SERVER1 stopped");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseLocator_With_SSL)
+ {
+ // stop locator
+ if (isLocator) {
+ CacheHelper::closeLocator(1, true);
+ LOG("Locator1 stopped");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_MAIN
+ {
+ CALL_TASK(CreateLocator1_With_SSL_untrustedCert);
+ CALL_TASK(CreateServer1_With_Locator_And_SSL_untrustedCert)
+
+ CALL_TASK(CreateClient1);
+
+ CALL_TASK(CreateRegions1_PoolLocators);
+
+ CALL_TASK(CloseCache1);
+ CALL_TASK(CloseServer1);
+
+ CALL_TASK(CloseLocator_With_SSL);
+ }
+END_MAIN
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/testThinClientSSLAuthFail.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSSLAuthFail.cpp b/src/cppcache/integration-test/testThinClientSSLAuthFail.cpp
index 660a8db..e6282f4 100644
--- a/src/cppcache/integration-test/testThinClientSSLAuthFail.cpp
+++ b/src/cppcache/integration-test/testThinClientSSLAuthFail.cpp
@@ -15,8 +15,180 @@
* limitations under the License.
*/
-#include "ThinClientSSLAuthFail.hpp"
+#include "fw_dunit.hpp"
+#include <geode/GeodeCppCache.hpp>
+#include <ace/OS.h>
+#include <ace/High_Res_Timer.h>
+#include <string>
+
+#define ROOT_NAME "ThinClientSSLAuthFail"
+#define ROOT_SCOPE DISTRIBUTED_ACK
+
+#include "CacheHelper.hpp"
+
+using namespace apache::geode::client;
+using namespace test;
+
+CacheHelper* cacheHelper = NULL;
+bool isLocalServer = false;
+
+static bool isLocator = false;
+const char* locatorsG =
+ CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
+
+#define CLIENT1 s1p1
+#define SERVER1 s2p1
+
+void initClient(const bool isthinClient) {
+ if (cacheHelper == NULL) {
+ PropertiesPtr props = Properties::create();
+ props->insert("ssl-enabled", "true");
+ std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
+ std::string pubkey = keystore + "/client_truststore.pem";
+ std::string privkey = keystore + "/client_keystore.pem";
+ props->insert("ssl-keystore", privkey.c_str());
+ props->insert("ssl-truststore", pubkey.c_str());
+ cacheHelper = new CacheHelper(isthinClient, props);
+ }
+ ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+}
+void cleanProc() {
+ if (cacheHelper != NULL) {
+ delete cacheHelper;
+ cacheHelper = NULL;
+ }
+}
+
+CacheHelper* getHelper() {
+ ASSERT(cacheHelper != NULL, "No cacheHelper initialized.");
+ return cacheHelper;
+}
+
+
+void createPooledRegion(const char* name, bool ackMode, const char* locators,
+ const char* poolname,
+ bool clientNotificationEnabled = false,
+ bool cachingEnable = true) {
+ LOG("createRegion_Pool() entered.");
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fflush(stdout);
+ RegionPtr regPtr =
+ getHelper()->createPooledRegion(name, ackMode, locators, poolname,
+ cachingEnable, clientNotificationEnabled);
+ ASSERT(regPtr != NULLPTR, "Failed to create region.");
+ LOG("Pooled Region created.");
+}
+
+void createEntry(const char* name, const char* key, const char* value) {
+ LOG("createEntry() entered.");
+ fprintf(stdout, "Creating entry -- key: %s value: %s in region %s\n", key,
+ value, name);
+ fflush(stdout);
+ // Create entry, verify entry is correct
+ CacheableKeyPtr keyPtr = createKey(key);
+ CacheableStringPtr valPtr = CacheableString::create(value);
+
+ RegionPtr regPtr = getHelper()->getRegion(name);
+ ASSERT(regPtr != NULLPTR, "Region not found.");
+
+ ASSERT(!regPtr->containsKey(keyPtr),
+ "Key should not have been found in region.");
+ ASSERT(!regPtr->containsValueForKey(keyPtr),
+ "Value should not have been found in region.");
+
+ // regPtr->create( keyPtr, valPtr );
+ regPtr->put(keyPtr, valPtr);
+ LOG("Created entry.");
+
+ //verifyEntry(name, key, value);
+ LOG("Entry created.");
+}
+
+
+
+const char* keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
+const char* vals[] = {"Value-1", "Value-2", "Value-3", "Value-4"};
+const char* nvals[] = {"New Value-1", "New Value-2", "New Value-3",
+ "New Value-4"};
+
+const char* regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
+
+const bool USE_ACK = true;
+const bool NO_ACK = false;
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateLocator1_With_SSL_untrustedCert)
+ {
+ // starting locator
+ if (isLocator) CacheHelper::initLocator(1, true, false, -1, 0, true);
+ LOG("Locator1 started with SSL");
+ }
+END_TASK_DEFINITION
+
+
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
+ {
+ // starting servers
+ if (isLocalServer) CacheHelper::initServer(1, NULL, locatorsG, NULL, true, true, false, false, true);
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
+ { initClient(true); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateRegions1_PoolLocators)
+ {
+ createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
+ true);
+ createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true);
+ RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
+ try {
+ regPtr->registerAllKeys(false, NULLPTR, false, false);
+ FAIL("Should have got NotConnectedException during registerAllKeys");
+ }
+ catch (NotConnectedException exp) {
+ LOG("Connection Failed as expected via NotConnectedException");
+ }
+ LOG("CreateRegions1_PoolLocators complete.");
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
+ { cleanProc(); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
+ {
+ if (isLocalServer) {
+ CacheHelper::closeServer(1);
+ LOG("SERVER1 stopped");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseLocator_With_SSL)
+ {
+ // stop locator
+ if (isLocator) {
+ CacheHelper::closeLocator(1, true);
+ LOG("Locator1 stopped");
+ }
+ }
+END_TASK_DEFINITION
DUNIT_MAIN
- { doThinClientSSL(true, true); }
+ {
+ CALL_TASK(CreateLocator1_With_SSL_untrustedCert);
+ CALL_TASK(CreateServer1_With_Locator_And_SSL_untrustedCert)
+
+ CALL_TASK(CreateClient1);
+
+ CALL_TASK(CreateRegions1_PoolLocators);
+
+ CALL_TASK(CloseCache1);
+ CALL_TASK(CloseServer1);
+
+ CALL_TASK(CloseLocator_With_SSL);
+ }
END_MAIN
http://git-wip-us.apache.org/repos/asf/geode-native/blob/8b67c130/src/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
----------------------------------------------------------------------
diff --git a/src/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp b/src/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
new file mode 100644
index 0000000..26214d9
--- /dev/null
+++ b/src/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+#include "fw_dunit.hpp"
+#include <geode/GeodeCppCache.hpp>
+#include <ace/OS.h>
+#include <ace/High_Res_Timer.h>
+#include <string>
+
+#define ROOT_NAME "ThinClientSSLAuthUntrusted"
+#define ROOT_SCOPE DISTRIBUTED_ACK
+
+#include "CacheHelper.hpp"
+
+using namespace apache::geode::client;
+using namespace test;
+
+CacheHelper* cacheHelper = NULL;
+bool isLocalServer = false;
+
+static bool isLocator = false;
+const char* locatorsG =
+ CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
+
+#define CLIENT1 s1p1
+#define SERVER1 s2p1
+
+void initClient(const bool isthinClient) {
+ if (cacheHelper == NULL) {
+ PropertiesPtr props = Properties::create();
+ props->insert("ssl-enabled", "true");
+ std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
+ std::string pubkey = keystore + "/client_truststore.pem";
+ std::string privkey = keystore + "/client_keystore_untrusted.pem";
+ props->insert("ssl-keystore", privkey.c_str());
+ props->insert("ssl-keystore-password", "secret");
+ props->insert("ssl-truststore", pubkey.c_str());
+ cacheHelper = new CacheHelper(isthinClient, props);
+ }
+ ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
+}
+void cleanProc() {
+ if (cacheHelper != NULL) {
+ delete cacheHelper;
+ cacheHelper = NULL;
+ }
+}
+
+CacheHelper* getHelper() {
+ ASSERT(cacheHelper != NULL, "No cacheHelper initialized.");
+ return cacheHelper;
+}
+
+
+void createPooledRegion(const char* name, bool ackMode, const char* locators,
+ const char* poolname,
+ bool clientNotificationEnabled = false,
+ bool cachingEnable = true) {
+ LOG("createRegion_Pool() entered.");
+ fprintf(stdout, "Creating region -- %s ackMode is %d\n", name, ackMode);
+ fflush(stdout);
+ RegionPtr regPtr =
+ getHelper()->createPooledRegion(name, ackMode, locators, poolname,
+ cachingEnable, clientNotificationEnabled);
+ ASSERT(regPtr != NULLPTR, "Failed to create region.");
+ LOG("Pooled Region created.");
+}
+
+void createEntry(const char* name, const char* key, const char* value) {
+ LOG("createEntry() entered.");
+ fprintf(stdout, "Creating entry -- key: %s value: %s in region %s\n", key,
+ value, name);
+ fflush(stdout);
+ // Create entry, verify entry is correct
+ CacheableKeyPtr keyPtr = createKey(key);
+ CacheableStringPtr valPtr = CacheableString::create(value);
+
+ RegionPtr regPtr = getHelper()->getRegion(name);
+ ASSERT(regPtr != NULLPTR, "Region not found.");
+
+ ASSERT(!regPtr->containsKey(keyPtr),
+ "Key should not have been found in region.");
+ ASSERT(!regPtr->containsValueForKey(keyPtr),
+ "Value should not have been found in region.");
+
+ // regPtr->create( keyPtr, valPtr );
+ regPtr->put(keyPtr, valPtr);
+ LOG("Created entry.");
+
+ //verifyEntry(name, key, value);
+ LOG("Entry created.");
+}
+
+
+
+const char* keys[] = {"Key-1", "Key-2", "Key-3", "Key-4"};
+const char* vals[] = {"Value-1", "Value-2", "Value-3", "Value-4"};
+const char* nvals[] = {"New Value-1", "New Value-2", "New Value-3",
+ "New Value-4"};
+
+const char* regionNames[] = {"DistRegionAck", "DistRegionNoAck"};
+
+const bool USE_ACK = true;
+const bool NO_ACK = false;
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateLocator1_With_SSL_untrustedCert)
+ {
+ // starting locator
+ if (isLocator) CacheHelper::initLocator(1, true, false, -1, 0, false);
+ LOG("Locator1 started with SSL");
+ }
+END_TASK_DEFINITION
+
+
+
+DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
+ {
+ // starting servers
+ if (isLocalServer) CacheHelper::initServer(1, NULL, locatorsG, NULL, true, true, false, false, false);
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateClient1)
+ { initClient(true); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CreateRegions1_PoolLocators)
+ {
+ createPooledRegion(regionNames[0], USE_ACK, locatorsG, "__TESTPOOL1_",
+ true);
+ createPooledRegion(regionNames[1], NO_ACK, locatorsG, "__TESTPOOL1_", true);
+ RegionPtr regPtr = getHelper()->getRegion(regionNames[0]);
+ try {
+ regPtr->registerAllKeys(false, NULLPTR, false, false);
+ FAIL("Should have got NotConnectedException during registerAllKeys");
+ }
+ catch (NotConnectedException exp) {
+ LOG("Connection Failed as expected via NotConnectedException");
+ }
+ LOG("CreateRegions1_PoolLocators complete.");
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
+ { cleanProc(); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
+ {
+ if (isLocalServer) {
+ CacheHelper::closeServer(1);
+ LOG("SERVER1 stopped");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(SERVER1, CloseLocator_With_SSL)
+ {
+ // stop locator
+ if (isLocator) {
+ CacheHelper::closeLocator(1, true);
+ LOG("Locator1 stopped");
+ }
+ }
+END_TASK_DEFINITION
+
+DUNIT_MAIN
+ {
+ CALL_TASK(CreateLocator1_With_SSL_untrustedCert);
+ CALL_TASK(CreateServer1_With_Locator_And_SSL_untrustedCert)
+
+ CALL_TASK(CreateClient1);
+
+ CALL_TASK(CreateRegions1_PoolLocators);
+
+ CALL_TASK(CloseCache1);
+ CALL_TASK(CloseServer1);
+
+ CALL_TASK(CloseLocator_With_SSL);
+ }
+END_MAIN