ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilArgon2IdPasswordEncoderTest Class Reference
+ Inheritance diagram for ilArgon2IdPasswordEncoderTest:
+ Collaboration diagram for ilArgon2IdPasswordEncoderTest:

Public Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 23 of file ilArgon2IdPasswordEncoderTest.php.

Member Function Documentation

◆ testEncoderDoesNotRelyOnSalts()

ilArgon2IdPasswordEncoderTest::testEncoderDoesNotRelyOnSalts ( ilArgon2idPasswordEncoder  $encoder)

Definition at line 72 of file ilArgon2IdPasswordEncoderTest.php.

References ilBasePasswordEncoder\requiresSalt().

72  : void
73  {
74  $this->assertFalse($encoder->requiresSalt());
75  }
requiresSalt()
Returns whether the encoder requires a salt.
+ Here is the call graph for this function:

◆ testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding()

ilArgon2IdPasswordEncoderTest::testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding ( ilArgon2idPasswordEncoder  $encoder)

Definition at line 51 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\encodePassword().

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

◆ testInstanceCanBeCreated()

ilArgon2IdPasswordEncoderTest::testInstanceCanBeCreated ( )

Definition at line 28 of file ilArgon2IdPasswordEncoderTest.php.

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

◆ testNameShouldBeArgon2id()

ilArgon2IdPasswordEncoderTest::testNameShouldBeArgon2id ( ilArgon2idPasswordEncoder  $encoder)

Definition at line 66 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\getName().

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

◆ testPasswordShouldBeCorrectlyEncodedAndVerified()

ilArgon2IdPasswordEncoderTest::testPasswordShouldBeCorrectlyEncodedAndVerified ( ilArgon2idPasswordEncoder  $encoder)

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)

Definition at line 59 of file ilArgon2IdPasswordEncoderTest.php.

References ilArgon2idPasswordEncoder\isPasswordValid().

61  : void {
62  $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), ''));
63  }
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)

Definition at line 78 of file ilArgon2IdPasswordEncoderTest.php.

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

78  : void
79  {
80  $raw = self::PASSWORD;
81 
82  $encoder->setThreads(2);
83  $encoder->setMemoryCost(4096);
84  $encoder->setTimeCost(8);
85  $encoded = $encoder->encodePassword($raw, '');
86 
87  $encoder->setThreads(2);
88  $encoder->setMemoryCost(4096);
89  $encoder->setTimeCost(8);
90  $this->assertFalse($encoder->requiresReencoding($encoded));
91 
92  $encoder->setThreads(2);
93  $encoder->setMemoryCost(4096);
94  $encoder->setTimeCost(4);
95  $this->assertTrue($encoder->requiresReencoding($encoded));
96 
97  $encoder->setThreads(1);
98  $encoder->setMemoryCost(4096);
99  $encoder->setTimeCost(8);
100  $this->assertTrue($encoder->requiresReencoding($encoded));
101 
102  $encoder->setThreads(2);
103  $encoder->setMemoryCost(2048);
104  $encoder->setTimeCost(8);
105  $this->assertTrue($encoder->requiresReencoding($encoded));
106  }
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 string ilArgon2IdPasswordEncoderTest::PASSWORD = 'password'
private

Definition at line 25 of file ilArgon2IdPasswordEncoderTest.php.

◆ WRONG_PASSWORD

const string ilArgon2IdPasswordEncoderTest::WRONG_PASSWORD = 'wrong_password'
private

Definition at line 26 of file ilArgon2IdPasswordEncoderTest.php.


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