Skip to content

Commit 3ae3cb3

Browse files
committed
Rename useSSL to useTLS and useTLS to useStartTLS
1 parent a78695f commit 3ae3cb3

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

src/Auth/Guard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function bind(?string $username = null, ?string $password = null): void
8080
// Prior to binding, we will upgrade our connectivity to TLS on our current
8181
// connection and ensure we are not already bound before upgrading.
8282
// This is to prevent subsequent upgrading on several binds.
83-
if ($this->connection->isUsingTLS() && ! $this->connection->isSecure()) {
83+
if ($this->connection->isUsingStartTLS() && ! $this->connection->isSecure()) {
8484
$this->connection->startTLS();
8585
}
8686

src/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ public function initialize(): void
148148
protected function configure(): void
149149
{
150150
if ($this->configuration->get('use_tls')) {
151-
$this->ldap->ssl();
151+
$this->ldap->setSSL();
152152
} elseif ($this->configuration->get('use_starttls')) {
153-
$this->ldap->tls();
153+
$this->ldap->setStartTLS();
154154
}
155155

156156
$this->ldap->setOptions(array_replace(

src/HandlesConnection.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,27 @@ trait HandlesConnection
4040
/**
4141
* Whether the connection must be bound over TLS (ldaps:// protocol).
4242
*/
43-
protected bool $useSSL = false;
43+
protected bool $useTLS = false;
4444

4545
/**
4646
* Whether the connection must be bound over STARTTLS (ldap:// with upgrade).
4747
*/
48-
protected bool $useTLS = false;
48+
protected bool $useStartTLS = false;
4949

5050
/**
5151
* {@inheritdoc}
5252
*/
53-
public function isUsingSSL(): bool
53+
public function isUsingTLS(): bool
5454
{
55-
return $this->useSSL;
55+
return $this->useTLS;
5656
}
5757

5858
/**
5959
* {@inheritdoc}
6060
*/
61-
public function isUsingTLS(): bool
61+
public function isUsingStartTLS(): bool
6262
{
63-
return $this->useTLS;
63+
return $this->useStartTLS;
6464
}
6565

6666
/**
@@ -92,25 +92,25 @@ public function isConnected(): bool
9292
*/
9393
public function canChangePasswords(): bool
9494
{
95-
return $this->isUsingSSL() || $this->isUsingTLS();
95+
return $this->isUsingTLS() || $this->isUsingStartTLS();
9696
}
9797

9898
/**
9999
* {@inheritdoc}
100100
*/
101-
public function ssl(bool $enabled = true): static
101+
public function setSSL(bool $enabled = true): static
102102
{
103-
$this->useSSL = $enabled;
103+
$this->useTLS = $enabled;
104104

105105
return $this;
106106
}
107107

108108
/**
109109
* {@inheritdoc}
110110
*/
111-
public function tls(bool $enabled = true): static
111+
public function setStartTLS(bool $enabled = true): static
112112
{
113-
$this->useTLS = $enabled;
113+
$this->useStartTLS = $enabled;
114114

115115
return $this;
116116
}
@@ -147,7 +147,7 @@ public function getConnection(): ?Connection
147147
public function getProtocol(): string
148148
{
149149
return $this->protocol ?: (
150-
$this->isUsingSSL()
150+
$this->isUsingTLS()
151151
? LdapInterface::PROTOCOL_SSL
152152
: LdapInterface::PROTOCOL
153153
);
@@ -168,7 +168,7 @@ protected function handleBindResponse(LdapResultResponse $response): void
168168
{
169169
$this->bound = $response->successful();
170170

171-
$this->secure = $this->secure ?: $this->bound && $this->isUsingSSL();
171+
$this->secure = $this->secure ?: $this->bound && $this->isUsingTLS();
172172
}
173173

174174
/**
@@ -233,7 +233,7 @@ protected function makeConnectionUris(array|string $hosts, string|int $port): st
233233
// If an attempt to connect via TLS protocol (ldaps://) is being performed,
234234
// and we are still using the default port, we will swap it
235235
// for the default TLS port, for developer convenience.
236-
if ($this->isUsingSSL() && $port == LdapInterface::PORT) {
236+
if ($this->isUsingTLS() && $port == LdapInterface::PORT) {
237237
$port = LdapInterface::PORT_SSL;
238238
}
239239

src/LdapInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,22 +285,22 @@ interface LdapInterface
285285
/**
286286
* Set the current connection to use TLS (ldaps:// protocol).
287287
*/
288-
public function ssl(): static;
288+
public function setSSL(): static;
289289

290290
/**
291291
* Determine if the current connection instance is using TLS (ldaps:// protocol).
292292
*/
293-
public function isUsingSSL(): bool;
293+
public function isUsingTLS(): bool;
294294

295295
/**
296296
* Set the current connection to use STARTTLS (ldap:// with upgrade).
297297
*/
298-
public function tls(): static;
298+
public function setStartTLS(): static;
299299

300300
/**
301301
* Determine if the current connection instance is using STARTTLS (ldap:// with upgrade).
302302
*/
303-
public function isUsingTLS(): bool;
303+
public function isUsingStartTLS(): bool;
304304

305305
/**
306306
* Determine if the connection is bound.

src/Testing/LdapFake.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,21 @@ public function countEntries(mixed $result): int
280280
/**
281281
* {@inheritdoc}
282282
*/
283-
public function isUsingSSL(): bool
283+
public function isUsingTLS(): bool
284284
{
285285
return $this->hasExpectations(__FUNCTION__)
286286
? $this->resolveExpectation(__FUNCTION__)
287-
: $this->useSSL;
287+
: $this->useTLS;
288288
}
289289

290290
/**
291291
* {@inheritdoc}
292292
*/
293-
public function isUsingTLS(): bool
293+
public function isUsingStartTLS(): bool
294294
{
295295
return $this->hasExpectations(__FUNCTION__)
296296
? $this->resolveExpectation(__FUNCTION__)
297-
: $this->useTLS;
297+
: $this->useStartTLS;
298298
}
299299

300300
/**

tests/Unit/Auth/GuardTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function test_starttls_is_only_upgraded_once_on_subsequent_binds()
251251
LdapFake::operation('bind')->once()->with('foo', 'bar')->andReturnResponse(1),
252252
]);
253253

254-
$ldap->tls();
254+
$ldap->setStartTLS();
255255

256256
$this->assertFalse($ldap->isSecure());
257257

tests/Unit/LdapTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public function test_construct_defaults()
1414
{
1515
$ldap = new Ldap;
1616

17+
$this->assertFalse($ldap->isUsingStartTLS());
1718
$this->assertFalse($ldap->isUsingTLS());
18-
$this->assertFalse($ldap->isUsingSSL());
1919
$this->assertFalse($ldap->isBound());
2020
$this->assertNull($ldap->getConnection());
2121
$this->assertEquals($ldap->getProtocol(), LdapInterface::PROTOCOL);
@@ -50,7 +50,7 @@ public function test_get_protocol_tls()
5050
{
5151
$ldap = new Ldap;
5252

53-
$ldap->ssl();
53+
$ldap->setSSL();
5454

5555
$this->assertEquals('ldaps://', $ldap->getProtocol());
5656
}
@@ -75,15 +75,15 @@ public function test_can_change_passwords()
7575
{
7676
$ldap = new Ldap;
7777

78-
$ldap->ssl();
78+
$ldap->setSSL();
7979

8080
$this->assertTrue($ldap->canChangePasswords());
8181

82-
$ldap->ssl(false);
82+
$ldap->setSSL(false);
8383

8484
$this->assertFalse($ldap->canChangePasswords());
8585

86-
$ldap->tls();
86+
$ldap->setStartTLS();
8787

8888
$this->assertTrue($ldap->canChangePasswords());
8989
}
@@ -113,7 +113,7 @@ public function test_is_secure_after_binding_with_a_tls_connection()
113113
LdapFake::operation('bind')->once()->andReturnResponse(),
114114
]);
115115

116-
$ldap->ssl();
116+
$ldap->setSSL();
117117

118118
$this->assertFalse($ldap->isSecure());
119119

0 commit comments

Comments
 (0)