Skip to content

Commit

Permalink
Fix closing ldap client in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuvindu committed Dec 6, 2024
1 parent 853a120 commit d22601c
Showing 1 changed file with 46 additions and 44 deletions.
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 d22601c

Please sign in to comment.