ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMd5PasswordEncoderTest.php
Go to the documentation of this file.
1<?php
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{
17 public function testInstanceCanBeCreated()
18 {
19 $encoder = new ilMd5PasswordEncoder();
20 $this->assertInstanceOf('ilMd5PasswordEncoder', $encoder);
21 return $encoder;
22 }
23
28 {
29 $this->assertSame(md5('password'), $encoder->encodePassword('password', ''));
30 }
31
36 {
37 $this->assertTrue($encoder->isPasswordValid(md5('password'), 'password', ''));
38 }
39
44 {
45 $this->assertFalse($encoder->requiresSalt());
46 }
47
52 {
53 $this->assertFalse($encoder->requiresReencoding('hello'));
54 }
55
61 {
62 $this->assertException(ilPasswordException::class);
63 $encoder->encodePassword(str_repeat('a', 5000), '');
64 }
65
70 {
71 $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), ''));
72 }
73
77 public function testNameShouldBeMd5(ilMd5PasswordEncoder $encoder)
78 {
79 $this->assertEquals('md5', $encoder->getName());
80 }
81}
An exception for terminatinating execution or to throw for unit testing.
requiresSalt()
{Returns whether or not the encoder requires a salt.boolean}
requiresReencoding($encoded)
{Returns whether or not the a encoded password needs to be re-encoded.boolean}
testEncoderDoesNotSupportReencoding(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testPasswordCanBeVerified(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated @expectedException ilPasswordException
testNameShouldBeMd5(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testPasswordShouldBeCorrectlyEncoded(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testEncoderDoesNotRelyOnSalts(ilMd5PasswordEncoder $encoder)
@depends testInstanceCanBeCreated
isPasswordValid($encoded, $raw, $salt)
{Checks a raw password against an encoded password.The raw password has to be injected into the encod...
encodePassword($raw, $salt)
{Encodes the raw password.string The encoded password}
getName()
{Returns a unique name/id of the concrete password encoder.string}
assertException($exception_class)