Skip to content

Commit 5fd061d

Browse files
author
Alexandr Bashurov
committed
Replace passwords with the PasswordProvider constant
1 parent 25bcec8 commit 5fd061d

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

tests/CustomerTest.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22
// Copyright 1999-2019. Plesk International GmbH.
33
namespace PleskXTest;
44

5+
use PleskXTest\Utility\PasswordProvider;
6+
57
class CustomerTest extends TestCase
68
{
7-
private $_customerProperties = [
8-
'cname' => 'Plesk',
9-
'pname' => 'John Smith',
10-
'login' => 'john-unit-test',
11-
'passwd' => 'simple-password',
12-
'email' => 'john@smith.com',
13-
'external-id' => 'link:12345',
14-
'description' => 'Good guy',
15-
];
9+
private $_customerProperties;
10+
11+
public function setUp()
12+
{
13+
$this->_customerProperties = [
14+
'cname' => 'Plesk',
15+
'pname' => 'John Smith',
16+
'login' => 'john-unit-test',
17+
'passwd' => PasswordProvider::STRONG_PASSWORD,
18+
'email' => 'john@smith.com',
19+
'external-id' => 'link:12345',
20+
'description' => 'Good guy',
21+
];
22+
}
1623

1724
public function testCreate()
1825
{
@@ -55,12 +62,12 @@ public function testGetAll()
5562
static::$_client->customer()->create([
5663
'pname' => 'John Smith',
5764
'login' => 'customer-a',
58-
'passwd' => 'simple-password',
65+
'passwd' => PasswordProvider::STRONG_PASSWORD,
5966
]);
6067
static::$_client->customer()->create([
6168
'pname' => 'Mike Black',
6269
'login' => 'customer-b',
63-
'passwd' => 'simple-password',
70+
'passwd' => PasswordProvider::STRONG_PASSWORD,
6471
]);
6572

6673
$customersInfo = static::$_client->customer()->getAll();

tests/DatabaseTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright 1999-2019. Plesk International GmbH.
33
namespace PleskXTest;
44

5+
use PleskXTest\Utility\PasswordProvider;
6+
57
class DatabaseTest extends TestCase
68
{
79
/** @var \PleskX\Api\Struct\Webspace\Info */
@@ -35,7 +37,7 @@ public function testCreateUser()
3537
$user = $this->_createUser([
3638
'db-id' => $database->id,
3739
'login' => 'test_user1',
38-
'password' => 'setup1Q',
40+
'password' => PasswordProvider::STRONG_PASSWORD,
3941
]);
4042
static::$_client->database()->deleteUser('id', $user->id);
4143
static::$_client->database()->delete('id', $database->id);
@@ -52,12 +54,12 @@ public function testUpdateUser()
5254
$user = $this->_createUser([
5355
'db-id' => $database->id,
5456
'login' => 'test_user1',
55-
'password' => 'setup1Q',
57+
'password' => PasswordProvider::STRONG_PASSWORD,
5658
]);
5759
$updatedUser = static::$_client->database()->updateUser([
5860
'id' => $user->id,
5961
'login' => 'test_user2',
60-
'password' => 'setup2Q',
62+
'password' => PasswordProvider::STRONG_PASSWORD,
6163
]);
6264
$this->assertEquals(true, $updatedUser);
6365
static::$_client->database()->deleteUser('id', $user->id);
@@ -118,7 +120,7 @@ public function testGetUserById()
118120
$user = $this->_createUser([
119121
'db-id' => $database->id,
120122
'login' => 'test_user1',
121-
'password' => 'setup1Q',
123+
'password' => PasswordProvider::STRONG_PASSWORD,
122124
]);
123125

124126
$dbUser = static::$_client->database()->getUser('id', $user->id);
@@ -146,19 +148,19 @@ public function testGetAllUsersByDbId()
146148
$user1 = $this->_createUser([
147149
'db-id' => $db1->id,
148150
'login' => 'test_user1',
149-
'password' => 'setup1Q',
151+
'password' => PasswordProvider::STRONG_PASSWORD,
150152
]);
151153

152154
$user2 = $this->_createUser([
153155
'db-id' => $db1->id,
154156
'login' => 'test_user2',
155-
'password' => 'setup1Q',
157+
'password' => PasswordProvider::STRONG_PASSWORD,
156158
]);
157159

158160
$user3 = $this->_createUser([
159161
'db-id' => $db2->id,
160162
'login' => 'test_user3',
161-
'password' => 'setup1Q',
163+
'password' => PasswordProvider::STRONG_PASSWORD,
162164
]);
163165

164166
$dbUsers = static::$_client->database()->getAllUsers('db-id', $db1->id);
@@ -196,7 +198,7 @@ public function testDeleteUser()
196198
$user = $this->_createUser([
197199
'db-id' => $database->id,
198200
'login' => 'test_user1',
199-
'password' => 'setup1Q',
201+
'password' => PasswordProvider::STRONG_PASSWORD,
200202
]);
201203

202204
$result = static::$_client->database()->deleteUser('id', $user->id);

tests/MailTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright 1999-2019. Plesk International GmbH.
33
namespace PleskXTest;
44

5+
use PleskXTest\Utility\PasswordProvider;
6+
57
class MailTest extends TestCase
68
{
79
/** @var \PleskX\Api\Struct\Webspace\Info */
@@ -35,7 +37,7 @@ protected function setUp()
3537

3638
public function testCreate()
3739
{
38-
$mailname = static::$_client->mail()->create('test', static::$webspace->id, true, 'secret');
40+
$mailname = static::$_client->mail()->create('test', static::$webspace->id, true, PasswordProvider::STRONG_PASSWORD);
3941

4042
$this->assertIsInt($mailname->id);
4143
$this->assertGreaterThan(0, $mailname->id);

tests/ProtectedDirectoryTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright 1999-2019. Plesk International GmbH.
33
namespace PleskXTest;
44

5+
use PleskXTest\Utility\PasswordProvider;
6+
57
class ProtectedDirectoryTest extends TestCase
68
{
79
/** @var \PleskX\Api\Struct\Webspace\Info */
@@ -64,7 +66,7 @@ public function testAddUser()
6466
{
6567
$protectedDirectory = static::$_client->protectedDirectory()->add('/', static::$webspace->id);
6668

67-
$user = static::$_client->protectedDirectory()->addUser($protectedDirectory, 'john', 'secret');
69+
$user = static::$_client->protectedDirectory()->addUser($protectedDirectory, 'john', PasswordProvider::STRONG_PASSWORD);
6870
$this->assertGreaterThan(0, $user->id);
6971

7072
static::$_client->protectedDirectory()->delete('id', $protectedDirectory->id);
@@ -74,7 +76,7 @@ public function testDeleteUser()
7476
{
7577
$protectedDirectory = static::$_client->protectedDirectory()->add('/', static::$webspace->id);
7678

77-
$user = static::$_client->protectedDirectory()->addUser($protectedDirectory, 'john', 'secret');
79+
$user = static::$_client->protectedDirectory()->addUser($protectedDirectory, 'john', PasswordProvider::STRONG_PASSWORD);
7880
$result = static::$_client->protectedDirectory()->deleteUser('id', $user->id);
7981
$this->assertTrue($result);
8082

tests/ResellerTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
// Copyright 1999-2019. Plesk International GmbH.
33
namespace PleskXTest;
44

5+
use PleskXTest\Utility\PasswordProvider;
6+
57
class ResellerTest extends TestCase
68
{
7-
private $_resellerProperties = [
8-
'pname' => 'John Reseller',
9-
'login' => 'reseller-unit-test',
10-
'passwd' => 'simple-password',
11-
];
9+
private $_resellerProperties;
10+
11+
public function setUp()
12+
{
13+
$this->_resellerProperties = [
14+
'pname' => 'John Reseller',
15+
'login' => 'reseller-unit-test',
16+
'passwd' => PasswordProvider::STRONG_PASSWORD,
17+
];
18+
}
1219

1320
public function testCreate()
1421
{
@@ -48,12 +55,12 @@ public function testGetAll()
4855
static::$_client->reseller()->create([
4956
'pname' => 'John Reseller',
5057
'login' => 'reseller-a',
51-
'passwd' => 'simple-password',
58+
'passwd' => PasswordProvider::STRONG_PASSWORD,
5259
]);
5360
static::$_client->reseller()->create([
5461
'pname' => 'Mike Reseller',
5562
'login' => 'reseller-b',
56-
'passwd' => 'simple-password',
63+
'passwd' => PasswordProvider::STRONG_PASSWORD,
5764
]);
5865

5966
$resellersInfo = static::$_client->reseller()->getAll();

tests/TestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Copyright 1999-2019. Plesk International GmbH.
33
namespace PleskXTest;
44

5+
use PleskXTest\Utility\PasswordProvider;
6+
57
abstract class TestCase extends \PHPUnit\Framework\TestCase
68
{
79
/** @var \PleskX\Api\Client */
@@ -52,15 +54,13 @@ protected static function _getIpAddress()
5254
protected static function _createWebspace()
5355
{
5456
$id = uniqid();
55-
$password = base64_encode(time());
56-
5757
$webspace = static::$_client->webspace()->create(
5858
[
5959
'name' => "test{$id}.test",
6060
'ip_address' => static::_getIpAddress(),
6161
], [
6262
'ftp_login' => "u{$id}",
63-
'ftp_password' => $password,
63+
'ftp_password' => PasswordProvider::STRONG_PASSWORD,
6464
]
6565
);
6666
self::$webspaces[] = $webspace;

0 commit comments

Comments
 (0)