fixup for new guard condition

This commit is contained in:
Richard Frith-Macdonald 2019-02-13 09:27:49 +00:00
parent cf62a50f52
commit 9afe522216

View file

@ -1,19 +1,37 @@
#import "ObjectTesting.h"
#import "../../../Headers/GNUstepBase/config.h"
#import "../../../Headers/Foundation/Foundation.h"
#ifdef HAVE_GNUTLS
#import "../../../Source/GSTLS.h"
#endif
#import "../../../Headers/GNUstepBase/GSTLS.h"
int
main() {
NSAutoreleasePool *arp = [NSAutoreleasePool new];
START_SET("TLS support")
#ifdef HAVE_GNUTLS
#if GS_USE_GNUTLS
#ifndef HAVE_GNUTLS_X509_PRIVKEY_IMPORT2
testHopeful = YES;
#endif
GSTLSPrivateKey *k = [GSTLSPrivateKey keyFromFile: @"test.key" withPassword: @"asdf"];
GSTLSPrivateKey *k;
GSTLSCertificateList *c;
NSDateFormatter *dateFormatter;
NSDate *expiresAt;
k = [GSTLSPrivateKey keyFromFile: @"test.key" withPassword: @"asdf"];
PASS(k != nil, "OpenSSL encrypted key can be loaded");
c = [GSTLSCertificateList listFromFile: @"test.crt"];
PASS(c != nil, "Certificate list can be loaded from a file");
PASS([c expiresAt: -1] == nil, "Return nil for invalid index");
PASS([c expiresAt: 2] == nil, "Return nil for invalid index");
expiresAt = [c expiresAt: 0];
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
PASS_EQUAL(expiresAt, [dateFormatter dateFromString: @"2118-12-14 15:35:11"],
"Expiration date can be retrieved");
[dateFormatter release];
PASS_EQUAL([c expiresAt], expiresAt,
"Expiration for entire list is that of the single item")
#else
SKIP("TLS support disabled");
#endif