Skip to content

Commit

Permalink
Merge pull request #77 from Nuvindu/master
Browse files Browse the repository at this point in the history
Fix closing ldap client instances in test cases
  • Loading branch information
chiranSachintha authored Dec 7, 2024
2 parents 3e01fc3 + d22601c commit e992623
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.11.0-20241121-075100-c4c87cbc"
distribution-version = "2201.11.0-20241204-163800-0d1e4836"

[[package]]
org = "ballerina"
Expand Down
90 changes: 46 additions & 44 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -283,57 +283,59 @@ public function testSearchWithInvalidType() returns error? {

@test:Config{}
public function testTlsConnection() returns error? {
ClientSecureSocket clientSecureSocket = {
cert: "tests/resources/server/certs/server.crt",
enable: true
};

Client ldapClient = check new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

ldapClient->close();
ClientSecureSocket clientSecureSocket = {
cert: "tests/resources/server/certs/server.crt",
enable: true
};

Client ldapClient = check new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

boolean isConnected = ldapClient->isConnected();
test:assertTrue(isConnected);
}

@test:Config{}
public function testTlsConnectionWithInvalidCert() returns error? {
ClientSecureSocket clientSecureSocket = {
cert: "tests/resources/server/certs/invalid.crt",
enable: true
};

Client|Error ldapClient = new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

test:assertTrue(ldapClient is Error);
ClientSecureSocket clientSecureSocket = {
cert: "tests/resources/server/certs/invalid.crt",
enable: true
};

Client|Error ldapClient = new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

test:assertTrue(ldapClient is Error);
}

@test:Config{}
public function testTlsConnectionWithTrustStore() returns error? {
ClientSecureSocket clientSecureSocket = {
cert: {
path: "tests/resources/server/certs/truststore.p12",
password: "password"
}
};

Client ldapClient = check new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

ldapClient->close();
ClientSecureSocket clientSecureSocket = {
cert: {
path: "tests/resources/server/certs/truststore.p12",
password: "password"
}
};

Client ldapClient = check new ({
port: 636,
hostName,
password,
domainName,
clientSecureSocket}
);

boolean isConnected = ldapClient->isConnected();
test:assertTrue(isConnected);
}

0 comments on commit e992623

Please sign in to comment.