Skip to content

Commit

Permalink
Updated internal test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobambini committed Dec 28, 2023
1 parent 3921852 commit 0c9e926
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Internals/old/
.DS_Store
Sample/MacOS/Client/cubeSQLTest.xcodeproj/project.pbxproj
Sample/Console/XCode/testapp.xcodeproj/xcshareddata/xcschemes/testapp.xcscheme
Internals/TestTLS/OpenSSL.xcodeproj/xcshareddata/xcschemes/OpenSSL.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
A9DB49D62209C94200C0E3F1 /* pseudorandom.c in Sources */ = {isa = PBXBuildFile; fileRef = A9DB49B32209C5C500C0E3F1 /* pseudorandom.c */; };
A9DB49D72209C94400C0E3F1 /* base64.c in Sources */ = {isa = PBXBuildFile; fileRef = A9DB49B52209C5C500C0E3F1 /* base64.c */; };
A9DB49D82209C94700C0E3F1 /* aestab.c in Sources */ = {isa = PBXBuildFile; fileRef = A9DB49B62209C5C500C0E3F1 /* aestab.c */; };
A9DFF2F82B3DA8FC00CAD971 /* libtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A9DFF2F72B3DA8FC00CAD971 /* libtls.a */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -47,13 +48,15 @@
A9DB49B72209C5C500C0E3F1 /* sha1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sha1.h; sourceTree = "<group>"; };
A9DB49B82209C5C500C0E3F1 /* csql.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = csql.h; sourceTree = "<group>"; };
A9DB49BE2209C5C500C0E3F1 /* cubesql.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cubesql.h; sourceTree = "<group>"; };
A9DFF2F72B3DA8FC00CAD971 /* libtls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtls.a; path = ../libs/macOS/libtls.a; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
A9DB499C2209C59200C0E3F1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A9DFF2F82B3DA8FC00CAD971 /* libtls.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -79,15 +82,16 @@
A9DB49A12209C59200C0E3F1 /* OpenSSL */ = {
isa = PBXGroup;
children = (
A9DB49A92209C5C500C0E3F1 /* C_SDK */,
A9DB49A22209C59200C0E3F1 /* main.c */,
A9DB49A92209C5C500C0E3F1 /* C_SDK */,
);
path = OpenSSL;
sourceTree = "<group>";
};
A9DB49A92209C5C500C0E3F1 /* C_SDK */ = {
isa = PBXGroup;
children = (
A9DFF2F72B3DA8FC00CAD971 /* libtls.a */,
A9DB49AA2209C5C500C0E3F1 /* cubesql.c */,
A9DB49BE2209C5C500C0E3F1 /* cubesql.h */,
A9DB49B82209C5C500C0E3F1 /* csql.h */,
Expand Down Expand Up @@ -305,11 +309,13 @@
DEVELOPMENT_TEAM = 3ZH6236ET5;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"CUBESQL_ENABLE_SSL_ENCRYPTION=1",
"CUBESQL_DYNAMIC_SSL_LIBRARY=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = "/Users/marco/GitHub/SQLabs/sdk/C_SDK/**";
HEADER_SEARCH_PATHS = (
"\"$(SRCROOT)/../../C_SDK/crypt\"",
"\"$(SRCROOT)/../../C_SDK\"",
);
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../libs/macOS\"";
OTHER_LDFLAGS = "-lz";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -320,11 +326,11 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 3ZH6236ET5;
GCC_PREPROCESSOR_DEFINITIONS = (
"CUBESQL_ENABLE_SSL_ENCRYPTION=1",
"CUBESQL_DYNAMIC_SSL_LIBRARY=1",
HEADER_SEARCH_PATHS = (
"\"$(SRCROOT)/../../C_SDK/crypt\"",
"\"$(SRCROOT)/../../C_SDK\"",
);
HEADER_SEARCH_PATHS = "/Users/marco/GitHub/SQLabs/sdk/C_SDK/**";
LIBRARY_SEARCH_PATHS = "\"$(SRCROOT)/../../libs/macOS\"";
OTHER_LDFLAGS = "-lz";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,32 @@ void print_cursor(csqlc *c) {
printf("\n");
}

int main(int argc, const char * argv[]) {
int do_test_clear (void) {
csqldb *db = NULL;

// "/Users/marco/Desktop/OpenSSL_1_macOS/libcrypto.1.0.0.dylib"
// "/Users/marco/Desktop/OpenSSL_1_macOS/libssl.1.0.0.dylib"
// "/Users/marco/Desktop/SQLabs/openssl/pluginissue_cert_win-64bit/Hosting.crt"
if (cubesql_connect(&db, HOSTNAME, CUBESQL_DEFAULT_PORT, USERNAME, PASSWORD, CUBESQL_DEFAULT_TIMEOUT, CUBESQL_ENCRYPTION_NONE) != CUBESQL_NOERR) goto abort;

// path to OpenSSL 1.1 libraries
// cubesql_setpath(CUBESQL_CRYPTO_LIBRARY_PATH, "/Users/marco/Desktop/SQLabs/openssl/libcrypto.1.1.dylib");
// cubesql_setpath(CUBESQL_SSL_LIBRARY_PATH, "/Users/marco/Desktop/SQLabs/openssl/libssl.1.1.dylib");
const char *certificatePath = NULL;// "/Users/marco/Desktop/SQLabs/openssl/pluginissue_cert_win-64bit/Hosting.crt";
do_test(db);

do_print_ssl();
// disconnect
cubesql_disconnect(db, kTRUE);
return 0;

// connection with SSL encryption
if (cubesql_connect_ssl(&db, HOSTNAME, CUBESQL_DEFAULT_PORT, USERNAME, PASSWORD, CUBESQL_DEFAULT_TIMEOUT, certificatePath) != CUBESQL_NOERR) {
goto abort;
abort:
do_print_ssl();
if (db) {
printf("error %d in cubesql_connect: %s\n", cubesql_errcode(db), cubesql_errmsg(db));
cubesql_disconnect(db, kFALSE);
}
return -1;
}

int do_test_tls (const char *rootCAFile) {
csqldb *db = NULL;

do_print_ssl();
if (cubesql_connect_token(&db, HOSTNAME, CUBESQL_DEFAULT_PORT, USERNAME, PASSWORD, CUBESQL_DEFAULT_TIMEOUT, CUBESQL_ENCRYPTION_SSL, NULL, kFALSE, NULL, rootCAFile, NULL, NULL) != CUBESQL_NOERR) goto abort;

do_test(db);

// disconnect
Expand All @@ -131,3 +137,11 @@ int main(int argc, const char * argv[]) {
}
return -1;
}


int main(int argc, const char * argv[]) {
do_test_clear();
do_test_tls(argv[1]);

return 0;
}

0 comments on commit 0c9e926

Please sign in to comment.