ILIAS  release_8 Revision v8.24
ilMd5PasswordEncoderTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29 {
30 $encoder = new ilMd5PasswordEncoder();
31 $this->assertInstanceOf(ilMd5PasswordEncoder::class, $encoder);
32 return $encoder;
33 }
34
40 {
41 $this->assertSame(md5('password'), $encoder->encodePassword('password', ''));
42 }
43
48 public function testPasswordCanBeVerified(ilMd5PasswordEncoder $encoder): void
49 {
50 $this->assertTrue($encoder->isPasswordValid(md5('password'), 'password', ''));
51 }
52
57 {
58 $this->assertFalse($encoder->requiresSalt());
59 }
60
65 {
66 $this->assertFalse($encoder->requiresReencoding('hello'));
67 }
68
75 ): void {
76 $this->expectException(ilPasswordException::class);
77 $encoder->encodePassword(str_repeat('a', 5000), '');
78 }
79
86 ): void {
87 $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), ''));
88 }
89
93 public function testNameShouldBeMd5(ilMd5PasswordEncoder $encoder): void
94 {
95 $this->assertSame('md5', $encoder->getName());
96 }
97}
requiresSalt()
Returns whether the encoder requires a salt.
requiresReencoding(string $encoded)
Returns whether the encoded password needs to be re-encoded.
testEncoderDoesNotSupportReencoding(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testPasswordCanBeVerified(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testNameShouldBeMd5(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testPasswordShouldBeCorrectlyEncoded(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testEncoderDoesNotRelyOnSalts(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
encodePassword(string $raw, string $salt)
Encodes the raw password.
getName()
Returns a unique name/id of the concrete password encoder.
isPasswordValid(string $encoded, string $raw, string $salt)
Checks a raw password against an encoded password.
Class for user password exception handling in ILIAS.