Skip to content

Commit

Permalink
Merge 518b308 into a467892
Browse files Browse the repository at this point in the history
  • Loading branch information
jayahariv committed Jul 2, 2020
2 parents a467892 + 518b308 commit 8727621
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 67 deletions.
32 changes: 24 additions & 8 deletions Objective-C/Tests/TLSIdentityTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ - (void) tearDown {
}

- (void) testCreateGetDeleteServerIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSError* error;
CBLTLSIdentity* identity;
Expand Down Expand Up @@ -237,7 +239,9 @@ - (void) testCreateGetDeleteServerIdentity {
}

- (void) testCreateDuplicateServerIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSError* error;
CBLTLSIdentity* identity;
Expand Down Expand Up @@ -272,7 +276,9 @@ - (void) testCreateDuplicateServerIdentity {
}

- (void) testCreateGetDeleteClientIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSError* error;
CBLTLSIdentity* identity;
Expand Down Expand Up @@ -316,7 +322,9 @@ - (void) testCreateGetDeleteClientIdentity {
}

- (void) testCreateDuplicateClientIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSError* error;
CBLTLSIdentity* identity;
Expand Down Expand Up @@ -351,7 +359,9 @@ - (void) testCreateDuplicateClientIdentity {
}

- (void) testGetIdentityWithIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

// Use SecPKCS12Import to import the PKCS12 data:
__block CFArrayRef result = NULL;
Expand Down Expand Up @@ -404,7 +414,9 @@ - (void) testGetIdentityWithIdentity {
}

- (void) testImportIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSData* data = [self dataFromResource: @"identity/certs" ofType: @"p12"];

Expand Down Expand Up @@ -442,7 +454,9 @@ - (void) testImportIdentity {
}

- (void) testCreateIdentityWithNoAttributes {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSError* error;
CBLTLSIdentity* identity;
Expand All @@ -469,7 +483,9 @@ - (void) testCreateIdentityWithNoAttributes {
}

- (void) testCertificateExpiration {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSError* error;
CBLTLSIdentity* identity;
Expand Down
60 changes: 45 additions & 15 deletions Objective-C/Tests/URLEndpointListenerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ - (void) testBusyPort {
}

- (void) testTLSIdentity {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

// Disabled TLS:
Config* config = [[Config alloc] initWithDatabase: self.otherDB];
Expand Down Expand Up @@ -364,7 +366,9 @@ - (void) testTLSIdentity {
}

- (void) testURLs {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

Config* config = [[Config alloc] initWithDatabase: self.otherDB];
_listener = [[Listener alloc] initWithConfig: config];
Expand Down Expand Up @@ -458,7 +462,9 @@ - (void) testPaswordAuthenticator {
}

- (void) testClientCertAuthenticatorWithBlock API_AVAILABLE(macos(10.12), ios(10.3)) {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

// Listener:
CBLListenerCertificateAuthenticator* listenerAuth =
Expand Down Expand Up @@ -506,7 +512,9 @@ - (void) testClientCertAuthenticatorWithBlock API_AVAILABLE(macos(10.12), ios(10
}

- (void) testClientCertAuthenticatorRootCerts {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSData* rootCertData = [self dataFromResource: @"identity/client-ca" ofType: @"der"];
SecCertificateRef rootCertRef = SecCertificateCreateWithData(kCFAllocatorDefault, (CFDataRef)rootCertData);
Expand Down Expand Up @@ -551,7 +559,9 @@ - (void) testClientCertAuthenticatorRootCerts {
}

- (void) testServerCertVerificationModeSelfSignedCert {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

// Listener:
Listener* listener = [self listenWithTLS: YES];
Expand Down Expand Up @@ -588,7 +598,9 @@ - (void) testServerCertVerificationModeSelfSignedCert {
}

- (void) testServerCertVerificationModeCACert {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

// Listener:
Listener* listener = [self listenWithTLS: YES];
Expand Down Expand Up @@ -625,7 +637,9 @@ - (void) testServerCertVerificationModeCACert {
}

- (void) testEmptyNetworkInterface {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

[self listen];
NSArray* urls = _listener.urls;
Expand Down Expand Up @@ -679,7 +693,9 @@ - (void) testEmptyNetworkInterface {
}

- (void) testUnavailableNetworkInterface {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

Config* config = [[Config alloc] initWithDatabase: self.otherDB];
config.networkInterface = @"1.1.1.256";
Expand All @@ -694,7 +710,9 @@ - (void) testUnavailableNetworkInterface {
}

- (void) testNetworkInterfaceName {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

NSArray* interfaces = [Listener allInterfaceNames];
for (NSString* i in interfaces) {
Expand All @@ -710,7 +728,9 @@ - (void) testNetworkInterfaceName {
}

- (void) testMultipleListenersOnSameDatabase {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

Config* config = [[Config alloc] initWithDatabase: self.otherDB];
Listener* listener1 = [[Listener alloc] initWithConfig: config];
Expand Down Expand Up @@ -739,7 +759,9 @@ - (void) testMultipleListenersOnSameDatabase {

// TODO: https://issues.couchbase.com/browse/CBL-1033
- (void) _testMultipleReplicatorsToListener {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

[self listen]; // writable listener

Expand All @@ -757,7 +779,9 @@ - (void) _testMultipleReplicatorsToListener {

// TODO: https://issues.couchbase.com/browse/CBL-1033
- (void) _testMultipleReplicatorsOnReadOnlyListener {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

Config* config = [[Config alloc] initWithDatabase: self.otherDB];
config.readOnly = YES;
Expand All @@ -781,7 +805,9 @@ - (void) _testMultipleReplicatorsOnReadOnlyListener {
3. Replicator#2 (DB#2 -> otherDB)
*/
- (void) testReplicatorAndListenerOnSameDatabase {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

XCTestExpectation* exp1 = [self expectationWithDescription: @"replicator#1 stopped"];
XCTestExpectation* exp2 = [self expectationWithDescription: @"replicator#2 stopped"];
Expand Down Expand Up @@ -851,7 +877,9 @@ - (void) testReplicatorAndListenerOnSameDatabase {

// TODO: https://issues.couchbase.com/browse/CBL-954
- (void) _testReadOnlyListener {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

Config* config = [[Config alloc] initWithDatabase: self.otherDB];
config.readOnly = YES;
Expand All @@ -873,7 +901,9 @@ - (void) _testReadOnlyListener {
}

- (void) testCloseWithActiveListener {
if (!self.keyChainAccessAllowed) return;
[self ignoreExceptionBreakPointOnly: ^{
XCTSkipUnless(self.keyChainAccessAllowed, @"Skipping, keychain not accessible in this config");
}];

[self listen];

Expand Down
16 changes: 8 additions & 8 deletions Swift/Tests/TLSIdentityTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testCreateGetDeleteServerIdentity() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Delete:
try TLSIdentity.deleteIdentity(withLabel: serverCertLabel)
Expand Down Expand Up @@ -183,7 +183,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testCreateDuplicateServerIdentity() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Create:
var identity: TLSIdentity?
Expand Down Expand Up @@ -211,7 +211,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testCreateGetDeleteClientIdentity() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Delete:
try TLSIdentity.deleteIdentity(withLabel: clientCertLabel)
Expand Down Expand Up @@ -245,7 +245,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testCreateDuplicateClientIdentity() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Create:
var identity: TLSIdentity?
Expand Down Expand Up @@ -273,7 +273,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testGetIdentityWithIdentity() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Use SecPKCS12Import to import the PKCS12 data:
var result : CFArray?
Expand Down Expand Up @@ -318,7 +318,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testImportIdentity() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

let data = try dataFromResource(name: "identity/certs", ofType: "p12")

Expand Down Expand Up @@ -351,7 +351,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testCreateIdentityWithNoAttributes() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Delete:
try TLSIdentity.deleteIdentity(withLabel: serverCertLabel)
Expand All @@ -370,7 +370,7 @@ class TLSIdentityTest: CBLTestCase {
}

func testCertificateExpiration() throws {
if (!keyChainAccessAllowed) { return }
try XCTSkipUnless(keyChainAccessAllowed, "Skipping, keychain is not allowed in this config")

// Delete:
try TLSIdentity.deleteIdentity(withLabel: serverCertLabel)
Expand Down
Loading

0 comments on commit 8727621

Please sign in to comment.