mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-23 15:56:59 +00:00
TOTPKey: Drop newFromString
Only used in tests. Change-Id: I4eb020eb507d5342e4e5ab8f92bf1ee22db0056b
This commit is contained in:
parent
0f026d7999
commit
370452d05b
|
@ -62,20 +62,6 @@ class TOTPKey implements IAuthKey {
|
|||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create key from json encoded string
|
||||
*
|
||||
* @param string $data
|
||||
* @return TOTPKey|null on invalid data
|
||||
*/
|
||||
public static function newFromString( $data ) {
|
||||
$data = json_decode( $data, true );
|
||||
if ( json_last_error() !== JSON_ERROR_NONE ) {
|
||||
return null;
|
||||
}
|
||||
return static::newFromArray( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return TOTPKey|null on invalid data
|
||||
|
|
|
@ -10,7 +10,7 @@ use MediaWiki\Extension\OATHAuth\Key\TOTPKey;
|
|||
class TOTPKeyTest extends \MediaWikiIntegrationTestCase {
|
||||
public function testDeserialization() {
|
||||
$key = TOTPKey::newFromRandom();
|
||||
$deserialized = TOTPKey::newFromString( json_encode( $key ) );
|
||||
$deserialized = TOTPKey::newFromArray( json_decode( json_encode( $key ), true ) );
|
||||
$this->assertSame( $key->getSecret(), $deserialized->getSecret() );
|
||||
$this->assertSame( $key->getScratchTokens(), $deserialized->getScratchTokens() );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue