ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilArgon2IdPasswordEncoderTest Class Reference
+ Inheritance diagram for ilArgon2IdPasswordEncoderTest:
+ Collaboration diagram for ilArgon2IdPasswordEncoderTest:

Public Member Functions

 testInstanceCanBeCreated ()
 
 testPasswordShouldBeCorrectlyEncodedAndVerified (ilArgon2idPasswordEncoder $encoder)
 testInstanceCanBeCreated More...
 
 testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding (ilArgon2idPasswordEncoder $encoder)
 testInstanceCanBeCreated More...
 
 testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength (ilArgon2idPasswordEncoder $encoder)
 testInstanceCanBeCreated More...
 
 testNameShouldBeArgon2id (ilArgon2idPasswordEncoder $encoder)
 testInstanceCanBeCreated More...
 
 testEncoderDoesNotRelyOnSalts (ilArgon2idPasswordEncoder $encoder)
 testInstanceCanBeCreated More...
 
 testReencodingIsDetectedWhenNecessary (ilArgon2idPasswordEncoder $encoder)
 testInstanceCanBeCreated More...
 

Private Attributes

const PASSWORD = 'password'
 
const WRONG_PASSWORD = 'wrong_password'
 

Detailed Description

Definition at line 21 of file ilArgon2IdPasswordEncoderTest.php.

Member Function Documentation

◆ testEncoderDoesNotRelyOnSalts()

ilArgon2IdPasswordEncoderTest::testEncoderDoesNotRelyOnSalts ( ilArgon2idPasswordEncoder  $encoder)

testInstanceCanBeCreated

Definition at line 80 of file ilArgon2IdPasswordEncoderTest.php.

References ilBasePasswordEncoder\requiresSalt().

80  : void
81  {
82  $this->assertFalse($encoder->requiresSalt());
83  }
requiresSalt()
Returns whether the encoder requires a salt.
+ Here is the call graph for this function:

◆ testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding()

ilArgon2IdPasswordEncoderTest::testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding ( ilArgon2idPasswordEncoder  $encoder)

testInstanceCanBeCreated

Definition at line 53 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\encodePassword().

55  : void {
56  $this->expectException(ilPasswordException::class);
57  $encoder->encodePassword(str_repeat('a', 5000), '');
58  }
encodePassword(string $raw, string $salt)
Encodes the raw password.
+ Here is the call graph for this function:

◆ testInstanceCanBeCreated()

ilArgon2IdPasswordEncoderTest::testInstanceCanBeCreated ( )

Definition at line 26 of file ilArgon2IdPasswordEncoderTest.php.

27  {
28  $encoder = new ilArgon2idPasswordEncoder();
29  $this->assertInstanceOf(ilArgon2idPasswordEncoder::class, $encoder);
30 
31  if (!$encoder->isSupportedByRuntime()) {
32  $this->markTestSkipped('Argon2id is not supported by the runtime.');
33  }
34 
35  return $encoder;
36  }

◆ testNameShouldBeArgon2id()

ilArgon2IdPasswordEncoderTest::testNameShouldBeArgon2id ( ilArgon2idPasswordEncoder  $encoder)

testInstanceCanBeCreated

Definition at line 72 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\getName().

72  : void
73  {
74  $this->assertSame('argon2id', $encoder->getName());
75  }
getName()
Returns a unique name/id of the concrete password encoder.
+ Here is the call graph for this function:

◆ testPasswordShouldBeCorrectlyEncodedAndVerified()

ilArgon2IdPasswordEncoderTest::testPasswordShouldBeCorrectlyEncodedAndVerified ( ilArgon2idPasswordEncoder  $encoder)

testInstanceCanBeCreated

Definition at line 41 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\encodePassword(), and ilArgon2idPasswordEncoder\isPasswordValid().

44  $encoded_password = $encoder->encodePassword(self::PASSWORD, '');
45  $this->assertTrue($encoder->isPasswordValid($encoded_password, self::PASSWORD, ''));
46  $this->assertFalse($encoder->isPasswordValid($encoded_password, self::WRONG_PASSWORD, ''));
47  return $encoder;
48  }
isPasswordValid(string $encoded, string $raw, string $salt)
Checks a raw password against an encoded password.
encodePassword(string $raw, string $salt)
Encodes the raw password.
+ Here is the call graph for this function:

◆ testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength()

ilArgon2IdPasswordEncoderTest::testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength ( ilArgon2idPasswordEncoder  $encoder)

testInstanceCanBeCreated

Definition at line 63 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\isPasswordValid().

65  : void {
66  $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), ''));
67  }
isPasswordValid(string $encoded, string $raw, string $salt)
Checks a raw password against an encoded password.
+ Here is the call graph for this function:

◆ testReencodingIsDetectedWhenNecessary()

ilArgon2IdPasswordEncoderTest::testReencodingIsDetectedWhenNecessary ( ilArgon2idPasswordEncoder  $encoder)

testInstanceCanBeCreated

Definition at line 88 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\encodePassword(), ilArgon2idPasswordEncoder\requiresReencoding(), ilArgon2idPasswordEncoder\setMemoryCost(), ilArgon2idPasswordEncoder\setThreads(), and ilArgon2idPasswordEncoder\setTimeCost().

88  : void
89  {
90  $raw = self::PASSWORD;
91 
92  $encoder->setThreads(2);
93  $encoder->setMemoryCost(4096);
94  $encoder->setTimeCost(8);
95  $encoded = $encoder->encodePassword($raw, '');
96 
97  $encoder->setThreads(2);
98  $encoder->setMemoryCost(4096);
99  $encoder->setTimeCost(8);
100  $this->assertFalse($encoder->requiresReencoding($encoded));
101 
102  $encoder->setThreads(2);
103  $encoder->setMemoryCost(4096);
104  $encoder->setTimeCost(4);
105  $this->assertTrue($encoder->requiresReencoding($encoded));
106 
107  $encoder->setThreads(1);
108  $encoder->setMemoryCost(4096);
109  $encoder->setTimeCost(8);
110  $this->assertTrue($encoder->requiresReencoding($encoded));
111 
112  $encoder->setThreads(2);
113  $encoder->setMemoryCost(2048);
114  $encoder->setTimeCost(8);
115  $this->assertTrue($encoder->requiresReencoding($encoded));
116  }
requiresReencoding(string $encoded)
Returns whether the encoded password needs to be re-encoded.
encodePassword(string $raw, string $salt)
Encodes the raw password.
+ Here is the call graph for this function:

Field Documentation

◆ PASSWORD

const ilArgon2IdPasswordEncoderTest::PASSWORD = 'password'
private

Definition at line 23 of file ilArgon2IdPasswordEncoderTest.php.

◆ WRONG_PASSWORD

const ilArgon2IdPasswordEncoderTest::WRONG_PASSWORD = 'wrong_password'
private

Definition at line 24 of file ilArgon2IdPasswordEncoderTest.php.


The documentation for this class was generated from the following file: