Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaneeldias committed Oct 20, 2023
1 parent 58d61a6 commit f2ecc95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ballerina/tests/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ballerina/sql;
import ballerinax/mssql.driver as _;

function getMssqlClient(string? database = (), int port = 1433) returns Client|error {
Client dbClient = check new (host, user, password, database, port);
Client dbClient = check new (host, user, password, database, port, options = {secureSocket: {encrypt:false}});
return dbClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public static Object createClient(BObject client, BMap<BString, Object> clientCo
}
BMap options = clientConfig.getMapValue(Constants.ClientConfiguration.OPTIONS);
String datasourceName = Constants.MSSQL_DATASOURCE_NAME;
BMap properties = Utils.generateOptionsMap(options);;
BMap properties = null;
Properties poolProperties = null;
if (options != null) {
// properties = Utils.generateOptionsMap(options);
properties = Utils.generateOptionsMap(options);
Object queryTimeout = properties.get(Constants.DatabaseProps.QUERY_TIMEOUT);
if (queryTimeout != null) {
poolProperties = new Properties();
Expand Down
10 changes: 5 additions & 5 deletions native/src/main/java/io/ballerina/stdlib/mssql/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
public class Utils {

public static BMap generateOptionsMap(BMap mssqlOptions) {
BMap<BString, Object> options = ValueCreator.createMapValue();
options.put(Constants.DatabaseProps.ENCRYPT, false);

if (mssqlOptions != null) {
BMap<BString, Object> options = ValueCreator.createMapValue();
addSSLOptions(mssqlOptions.getMapValue(Constants.Options.SECURE_SOCKET), options);

long queryTimeout = getTimeout(mssqlOptions.get(Constants.Options.QUERY_TIMEOUT_SECONDS));
Expand All @@ -52,8 +51,9 @@ public static BMap generateOptionsMap(BMap mssqlOptions) {
options.put(Constants.DatabaseProps.LOGIN_TIMEOUT, loginTimeout);
}

return options;
}
return options;
return null;
}

private static int getBooleanValue(Object value) {
Expand All @@ -80,8 +80,8 @@ private static void addSSLOptions(BMap sslConfig, BMap<BString, Object> options)
if (sslConfig != null) {

int encrypt = getBooleanValue(sslConfig.get(Constants.SSLConfig.ENCRYPT));
if (encrypt == 1) {
options.put(Constants.DatabaseProps.ENCRYPT, true);
if (encrypt == 0) {
options.put(Constants.DatabaseProps.ENCRYPT, false);
}

int trustServerCertificate = getBooleanValue(sslConfig.get(Constants.SSLConfig.TRUST_SERVER_CERTIFICATE));
Expand Down

0 comments on commit f2ecc95

Please sign in to comment.