Documentation

TotpTest extends TestCase
in package

Table of Contents

CODE_NOW  = "081804"
ERROR_INVALID_SECRET  = "The two factor secret is not valid Base32."
NOW  = 1111111109
RFC_SECRET  = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"
rfc6238Vectors()  : array<string|int, mixed>
testAcceptsTheCodeOfTheCurrentPeriod()  : void
testAcceptsTheCodeOfThePeriodBeforeAndAfter()  : void
testCarriesIssuerLabelAndSecretInTheFormAuthenticatorsRead()  : void
testCreateBuildsSameInstanceAsConstructor()  : void
testDropsAColonFromTheLabelAndTheIssuerWhichSeparatesTheTwo()  : void
testEmptySecretThrowsException()  : void
testGeneratedSecretYieldsCodesThatVerify()  : void
testGenerateSecretReturns32Base32Characters()  : void
testGenerateSecretReturnsDifferentSecretEveryTime()  : void
testGetSecretReturnsSecretAsGiven()  : void
testKeepsTheCodeForAWholePeriodAndChangesItWithTheNext()  : void
testMatchesTheRfc6238VectorFor()  : void
testNowVerifiesWithoutTimestamp()  : void
testProvisioningUriWithoutIssuerNamesOnlyLabel()  : void
testReadsASecretRegardlessOfCaseAndPadding()  : void
testRejectsACodeTwoPeriodsAway()  : void
testRejectsAWrongCodeAndACodeOfTheWrongLength()  : void
testSecretOfOnlyPaddingThrowsException()  : void
testSecretTooShortForAByteThrowsException()  : void
testSecretWithCharacterOutsideAlphabetThrowsException()  : void
testSecretWithPaddingInTheMiddleThrowsException()  : void
testSecretWithWhitespaceThrowsException()  : void
testVerifyToleratesOnePeriodByDefault()  : void
testVerifyWithoutDriftAcceptsOnlyCurrentPeriod()  : void
testVerifyWithWiderDriftAcceptsPeriodsFurtherAway()  : void
wrongCodes()  : array<string|int, mixed>
getTotp()  : Totp

Constants

CODE_NOW

private mixed CODE_NOW = "081804"

ERROR_INVALID_SECRET

private mixed ERROR_INVALID_SECRET = "The two factor secret is not valid Base32."

RFC_SECRET

private mixed RFC_SECRET = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"

Methods

rfc6238Vectors()

public static rfc6238Vectors() : array<string|int, mixed>
Return values
array<string|int, mixed> —

testAcceptsTheCodeOfTheCurrentPeriod()

public testAcceptsTheCodeOfTheCurrentPeriod() : void
Return values
void —

testAcceptsTheCodeOfThePeriodBeforeAndAfter()

public testAcceptsTheCodeOfThePeriodBeforeAndAfter() : void
Return values
void —

testCarriesIssuerLabelAndSecretInTheFormAuthenticatorsRead()

public testCarriesIssuerLabelAndSecretInTheFormAuthenticatorsRead() : void
Return values
void —

testCreateBuildsSameInstanceAsConstructor()

public testCreateBuildsSameInstanceAsConstructor() : void
Return values
void —

testDropsAColonFromTheLabelAndTheIssuerWhichSeparatesTheTwo()

public testDropsAColonFromTheLabelAndTheIssuerWhichSeparatesTheTwo() : void
Return values
void —

testEmptySecretThrowsException()

public testEmptySecretThrowsException() : void
Return values
void —

testGeneratedSecretYieldsCodesThatVerify()

public testGeneratedSecretYieldsCodesThatVerify() : void
Tags
depends

testGenerateSecretReturns32Base32Characters

Return values
void —

testGenerateSecretReturns32Base32Characters()

public testGenerateSecretReturns32Base32Characters() : void
Return values
void —

testGenerateSecretReturnsDifferentSecretEveryTime()

public testGenerateSecretReturnsDifferentSecretEveryTime() : void
Return values
void —

testGetSecretReturnsSecretAsGiven()

public testGetSecretReturnsSecretAsGiven() : void
Return values
void —

testKeepsTheCodeForAWholePeriodAndChangesItWithTheNext()

public testKeepsTheCodeForAWholePeriodAndChangesItWithTheNext() : void
Return values
void —

testMatchesTheRfc6238VectorFor()

public testMatchesTheRfc6238VectorFor(int $timestamp, string $expected) : void
Parameters
$timestamp : int
$expected : string
Tags
dataProvider

rfc6238Vectors

Return values
void —

testNowVerifiesWithoutTimestamp()

public testNowVerifiesWithoutTimestamp() : void
Return values
void —

testProvisioningUriWithoutIssuerNamesOnlyLabel()

public testProvisioningUriWithoutIssuerNamesOnlyLabel() : void
Return values
void —

testReadsASecretRegardlessOfCaseAndPadding()

public testReadsASecretRegardlessOfCaseAndPadding() : void
Return values
void —

testRejectsACodeTwoPeriodsAway()

public testRejectsACodeTwoPeriodsAway() : void
Return values
void —

testRejectsAWrongCodeAndACodeOfTheWrongLength()

public testRejectsAWrongCodeAndACodeOfTheWrongLength(string $code) : void
Parameters
$code : string
Tags
dataProvider

wrongCodes

Return values
void —

testSecretOfOnlyPaddingThrowsException()

public testSecretOfOnlyPaddingThrowsException() : void
Return values
void —

testSecretTooShortForAByteThrowsException()

public testSecretTooShortForAByteThrowsException() : void
Return values
void —

testSecretWithCharacterOutsideAlphabetThrowsException()

public testSecretWithCharacterOutsideAlphabetThrowsException() : void
Return values
void —

testSecretWithPaddingInTheMiddleThrowsException()

public testSecretWithPaddingInTheMiddleThrowsException() : void
Return values
void —

testSecretWithWhitespaceThrowsException()

public testSecretWithWhitespaceThrowsException() : void
Return values
void —

testVerifyToleratesOnePeriodByDefault()

public testVerifyToleratesOnePeriodByDefault() : void
Return values
void —

testVerifyWithoutDriftAcceptsOnlyCurrentPeriod()

public testVerifyWithoutDriftAcceptsOnlyCurrentPeriod() : void
Return values
void —

testVerifyWithWiderDriftAcceptsPeriodsFurtherAway()

public testVerifyWithWiderDriftAcceptsPeriodsFurtherAway() : void
Return values
void —

wrongCodes()

public static wrongCodes() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getTotp()

protected getTotp([string $secret = self::RFC_SECRET ]) : Totp
Parameters
$secret : string = self::RFC_SECRET
Return values
Totp —

Search results