Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix closing ldap client instances in test cases #77

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

Loading