ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMd5PasswordEncoderTest.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Password/classes/encoders/class.ilMd5PasswordEncoder.php';
5require_once 'Services/Password/test/ilPasswordBaseTest.php';
6
13{
18 {
19 $encoder = new ilMd5PasswordEncoder();
20 $this->assertInstanceOf('ilMd5PasswordEncoder', $encoder);
21 return $encoder;
22 }
23
30 {
31 $this->assertSame(md5('password'), $encoder->encodePassword('password', ''));
32 }
33
39 public function testPasswordCanBeVerified(ilMd5PasswordEncoder $encoder) : void
40 {
41 $this->assertTrue($encoder->isPasswordValid(md5('password'), 'password', ''));
42 }
43
48 public function testEncoderDoesNotRelyOnSalts(ilMd5PasswordEncoder $encoder) : void
49 {
50 $this->assertFalse($encoder->requiresSalt());
51 }
52
58 {
59 $this->assertFalse($encoder->requiresReencoding('hello'));
60 }
61
69 ) : void {
70 $this->expectException(ilPasswordException::class);
71 $encoder->encodePassword(str_repeat('a', 5000), '');
72 }
73
81 ) : void {
82 $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), ''));
83 }
84
89 public function testNameShouldBeMd5(ilMd5PasswordEncoder $encoder) : void
90 {
91 $this->assertEquals('md5', $encoder->getName());
92 }
93}
An exception for terminatinating execution or to throw for unit testing.
requiresReencoding(string $encoded)
@inheritDoc
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)
@inheritDoc
isPasswordValid(string $encoded, string $raw, string $salt)
@inheritDoc
Class for user password exception handling in ILIAS.