TOTPKey: Drop newFromString

Only used in tests.

Change-Id: I4eb020eb507d5342e4e5ab8f92bf1ee22db0056b
This commit is contained in:
Taavi Väänänen 2024-01-01 19:36:10 +02:00 committed by Reedy
parent 0f026d7999
commit 370452d05b
2 changed files with 1 additions and 15 deletions

View file

@ -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

View file

@ -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() );
}