MigratorTest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <?php
  2. namespace Tests\Unit;
  3. use App\Exceptions\EncryptedMigrationException;
  4. use App\Exceptions\InvalidMigrationDataException;
  5. use App\Exceptions\UnsupportedMigrationException;
  6. use App\Factories\MigratorFactory;
  7. use App\Models\TwoFAccount;
  8. use App\Services\LogoService;
  9. use App\Services\Migrators\AegisMigrator;
  10. use App\Services\Migrators\GoogleAuthMigrator;
  11. use App\Services\Migrators\Migrator;
  12. use App\Services\Migrators\PlainTextMigrator;
  13. use App\Services\Migrators\TwoFASMigrator;
  14. use App\Services\Migrators\TwoFAuthMigrator;
  15. use App\Services\SettingService;
  16. use Illuminate\Support\Facades\Storage;
  17. use Mockery;
  18. use Mockery\MockInterface;
  19. use ParagonIE\ConstantTime\Base32;
  20. use Tests\Data\MigrationTestData;
  21. use Tests\Data\OtpTestData;
  22. use Tests\TestCase;
  23. /**
  24. * @covers \App\Providers\MigrationServiceProvider
  25. * @covers \App\Factories\MigratorFactory
  26. * @covers \App\Services\Migrators\Migrator
  27. * @covers \App\Services\Migrators\AegisMigrator
  28. * @covers \App\Services\Migrators\TwoFASMigrator
  29. * @covers \App\Services\Migrators\PlainTextMigrator
  30. * @covers \App\Services\Migrators\GoogleAuthMigrator
  31. * @covers \App\Services\Migrators\TwoFAuthMigrator
  32. *
  33. * @uses \App\Models\TwoFAccount
  34. */
  35. class MigratorTest extends TestCase
  36. {
  37. /**
  38. * App\Models\TwoFAccount $totpTwofaccount
  39. */
  40. protected $totpTwofaccount;
  41. /**
  42. * App\Models\TwoFAccount $totpTwofaccount
  43. */
  44. protected $hotpTwofaccount;
  45. /**
  46. * App\Models\TwoFAccount $steamTwofaccount
  47. */
  48. protected $steamTwofaccount;
  49. /**
  50. * App\Models\TwoFAccount $GAuthTotpTwofaccount
  51. */
  52. protected $GAuthTotpTwofaccount;
  53. /**
  54. * App\Models\TwoFAccount $GAuthTotpBisTwofaccount
  55. */
  56. protected $GAuthTotpBisTwofaccount;
  57. protected $fakeTwofaccount;
  58. public function setUp() : void
  59. {
  60. parent::setUp();
  61. $this->mock(SettingService::class, function (MockInterface $settingService) {
  62. $settingService->allows()
  63. ->get('useEncryption')
  64. ->andReturn(false);
  65. });
  66. $this->mock(LogoService::class, function (MockInterface $logoService) {
  67. $logoService->allows([
  68. 'getIcon' => null,
  69. ]);
  70. });
  71. $this->totpTwofaccount = new TwoFAccount;
  72. $this->totpTwofaccount->legacy_uri = OtpTestData::TOTP_FULL_CUSTOM_URI_NO_IMG;
  73. $this->totpTwofaccount->service = OtpTestData::SERVICE;
  74. $this->totpTwofaccount->account = OtpTestData::ACCOUNT;
  75. $this->totpTwofaccount->icon = null;
  76. $this->totpTwofaccount->otp_type = 'totp';
  77. $this->totpTwofaccount->secret = OtpTestData::SECRET;
  78. $this->totpTwofaccount->digits = OtpTestData::DIGITS_CUSTOM;
  79. $this->totpTwofaccount->algorithm = OtpTestData::ALGORITHM_CUSTOM;
  80. $this->totpTwofaccount->period = OtpTestData::PERIOD_CUSTOM;
  81. $this->totpTwofaccount->counter = null;
  82. $this->hotpTwofaccount = new TwoFAccount;
  83. $this->hotpTwofaccount->legacy_uri = OtpTestData::HOTP_FULL_CUSTOM_URI_NO_IMG;
  84. $this->hotpTwofaccount->service = OtpTestData::SERVICE;
  85. $this->hotpTwofaccount->account = OtpTestData::ACCOUNT;
  86. $this->hotpTwofaccount->icon = null;
  87. $this->hotpTwofaccount->otp_type = 'hotp';
  88. $this->hotpTwofaccount->secret = OtpTestData::SECRET;
  89. $this->hotpTwofaccount->digits = OtpTestData::DIGITS_CUSTOM;
  90. $this->hotpTwofaccount->algorithm = OtpTestData::ALGORITHM_CUSTOM;
  91. $this->hotpTwofaccount->period = null;
  92. $this->hotpTwofaccount->counter = OtpTestData::COUNTER_CUSTOM;
  93. $this->steamTwofaccount = new TwoFAccount;
  94. $this->steamTwofaccount->legacy_uri = OtpTestData::STEAM_TOTP_URI;
  95. $this->steamTwofaccount->service = OtpTestData::STEAM;
  96. $this->steamTwofaccount->account = OtpTestData::ACCOUNT;
  97. $this->steamTwofaccount->icon = null;
  98. $this->steamTwofaccount->otp_type = 'steamtotp';
  99. $this->steamTwofaccount->secret = OtpTestData::STEAM_SECRET;
  100. $this->steamTwofaccount->digits = OtpTestData::DIGITS_STEAM;
  101. $this->steamTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT;
  102. $this->steamTwofaccount->period = OtpTestData::PERIOD_DEFAULT;
  103. $this->steamTwofaccount->counter = null;
  104. $this->GAuthTotpTwofaccount = new TwoFAccount;
  105. $this->GAuthTotpTwofaccount->service = OtpTestData::SERVICE;
  106. $this->GAuthTotpTwofaccount->account = OtpTestData::ACCOUNT;
  107. $this->GAuthTotpTwofaccount->icon = null;
  108. $this->GAuthTotpTwofaccount->otp_type = 'totp';
  109. $this->GAuthTotpTwofaccount->secret = OtpTestData::SECRET;
  110. $this->GAuthTotpTwofaccount->digits = OtpTestData::DIGITS_DEFAULT;
  111. $this->GAuthTotpTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT;
  112. $this->GAuthTotpTwofaccount->period = OtpTestData::PERIOD_DEFAULT;
  113. $this->GAuthTotpTwofaccount->counter = null;
  114. $this->GAuthTotpBisTwofaccount = new TwoFAccount;
  115. $this->GAuthTotpBisTwofaccount->service = OtpTestData::SERVICE . '_bis';
  116. $this->GAuthTotpBisTwofaccount->account = OtpTestData::ACCOUNT . '_bis';
  117. $this->GAuthTotpBisTwofaccount->icon = null;
  118. $this->GAuthTotpBisTwofaccount->otp_type = 'totp';
  119. $this->GAuthTotpBisTwofaccount->secret = OtpTestData::SECRET;
  120. $this->GAuthTotpBisTwofaccount->digits = OtpTestData::DIGITS_DEFAULT;
  121. $this->GAuthTotpBisTwofaccount->algorithm = OtpTestData::ALGORITHM_DEFAULT;
  122. $this->GAuthTotpBisTwofaccount->period = OtpTestData::PERIOD_DEFAULT;
  123. $this->GAuthTotpBisTwofaccount->counter = null;
  124. $this->fakeTwofaccount = new TwoFAccount;
  125. $this->fakeTwofaccount->id = TwoFAccount::FAKE_ID;
  126. }
  127. /**
  128. * @test
  129. *
  130. * @dataProvider validMigrationsProvider
  131. */
  132. public function test_migrate_returns_consistent_accounts(Migrator $migrator, mixed $payload, string $expected, bool $hasSteam)
  133. {
  134. $accounts = $migrator->migrate($payload);
  135. if ($expected === 'gauth') {
  136. $totp = $this->GAuthTotpTwofaccount;
  137. $hotp = $this->GAuthTotpBisTwofaccount;
  138. } else {
  139. $totp = $this->totpTwofaccount;
  140. $hotp = $this->hotpTwofaccount;
  141. if ($hasSteam) {
  142. $steam = $this->steamTwofaccount;
  143. }
  144. }
  145. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  146. $this->assertCount($hasSteam ? 3 : 2, $accounts);
  147. // The returned collection could have non-linear index (because of possible blank lines
  148. // in the migration payload) so we do not use get() to retrieve items
  149. $this->assertObjectEquals($totp, $accounts->first());
  150. $this->assertObjectEquals($hotp, $accounts->slice(1, 1)->first());
  151. if ($hasSteam) {
  152. $this->assertObjectEquals($steam, $accounts->last());
  153. }
  154. }
  155. /**
  156. * Provide data for TwoFAccount store tests
  157. */
  158. public function validMigrationsProvider()
  159. {
  160. return [
  161. 'PLAIN_TEXT_PAYLOAD' => [
  162. new PlainTextMigrator(),
  163. MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD,
  164. 'custom',
  165. $hasSteam = true,
  166. ],
  167. 'PLAIN_TEXT_PAYLOAD_WITH_INTRUDER' => [
  168. new PlainTextMigrator(),
  169. MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD_WITH_INTRUDER,
  170. 'custom',
  171. $hasSteam = true,
  172. ],
  173. 'AEGIS_JSON_MIGRATION_PAYLOAD' => [
  174. new AegisMigrator(),
  175. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD,
  176. 'custom',
  177. $hasSteam = true,
  178. ],
  179. '2FAS_MIGRATION_PAYLOAD' => [
  180. new TwoFASMigrator(),
  181. MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD,
  182. 'custom',
  183. $hasSteam = false,
  184. ],
  185. 'GOOGLE_AUTH_MIGRATION_PAYLOAD' => [
  186. new GoogleAuthMigrator(),
  187. MigrationTestData::GOOGLE_AUTH_MIGRATION_URI,
  188. 'gauth',
  189. $hasSteam = false,
  190. ],
  191. '2FAUTH_MIGRATION_PAYLOAD' => [
  192. new TwoFAuthMigrator(),
  193. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD,
  194. 'custom',
  195. $hasSteam = true,
  196. ],
  197. ];
  198. }
  199. /**
  200. * @test
  201. *
  202. * @dataProvider invalidMigrationsProvider
  203. */
  204. public function test_migrate_with_invalid_payload_returns_InvalidMigrationDataException(Migrator $migrator, mixed $payload)
  205. {
  206. $this->expectException(InvalidMigrationDataException::class);
  207. $accounts = $migrator->migrate($payload);
  208. }
  209. /**
  210. * Provide data for TwoFAccount store tests
  211. */
  212. public function invalidMigrationsProvider()
  213. {
  214. return [
  215. 'INVALID_PLAIN_TEXT_NO_URI' => [
  216. new PlainTextMigrator(),
  217. MigrationTestData::INVALID_PLAIN_TEXT_NO_URI,
  218. ],
  219. 'INVALID_PLAIN_TEXT_ONLY_EMPTY_LINES' => [
  220. new PlainTextMigrator(),
  221. MigrationTestData::INVALID_PLAIN_TEXT_ONLY_EMPTY_LINES,
  222. ],
  223. 'INVALID_PLAIN_TEXT_NULL' => [
  224. new PlainTextMigrator(),
  225. null,
  226. ],
  227. 'INVALID_PLAIN_TEXT_EMPTY_STRING' => [
  228. new PlainTextMigrator(),
  229. '',
  230. ],
  231. 'INVALID_PLAIN_TEXT_INT' => [
  232. new PlainTextMigrator(),
  233. 10,
  234. ],
  235. 'INVALID_PLAIN_TEXT_BOOL' => [
  236. new PlainTextMigrator(),
  237. true,
  238. ],
  239. 'INVALID_AEGIS_JSON_MIGRATION_PAYLOAD' => [
  240. new AegisMigrator(),
  241. MigrationTestData::INVALID_AEGIS_JSON_MIGRATION_PAYLOAD,
  242. ],
  243. 'ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD' => [
  244. new AegisMigrator(),
  245. MigrationTestData::ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD,
  246. ],
  247. 'INVALID_2FAS_MIGRATION_PAYLOAD' => [
  248. new TwoFASMigrator(),
  249. MigrationTestData::INVALID_2FAS_MIGRATION_PAYLOAD,
  250. ],
  251. 'INVALID_GOOGLE_AUTH_MIGRATION_URI' => [
  252. new GoogleAuthMigrator(),
  253. MigrationTestData::INVALID_GOOGLE_AUTH_MIGRATION_URI,
  254. ],
  255. 'GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA' => [
  256. new GoogleAuthMigrator(),
  257. MigrationTestData::GOOGLE_AUTH_MIGRATION_URI_WITH_INVALID_DATA,
  258. ],
  259. 'INVALID_2FAUTH_JSON_MIGRATION_PAYLOAD' => [
  260. new TwoFAuthMigrator(),
  261. MigrationTestData::INVALID_2FAUTH_JSON_MIGRATION_PAYLOAD,
  262. ],
  263. ];
  264. }
  265. /**
  266. * @test
  267. *
  268. * @dataProvider migrationWithInvalidAccountsProvider
  269. */
  270. public function test_migrate_returns_fake_accounts(Migrator $migrator, mixed $payload)
  271. {
  272. $accounts = $migrator->migrate($payload);
  273. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  274. $this->assertCount(2, $accounts);
  275. // The returned collection could have non-linear index (because of possible blank lines
  276. // in the migration payload) so we do not use get() to retrieve items
  277. $this->assertObjectEquals($this->totpTwofaccount, $accounts->first());
  278. $this->assertEquals($this->fakeTwofaccount->id, $accounts->last()->id);
  279. }
  280. /**
  281. * Provide data for TwoFAccount store tests
  282. */
  283. public function migrationWithInvalidAccountsProvider()
  284. {
  285. return [
  286. 'PLAIN_TEXT_PAYLOAD_WITH_INVALID_URI' => [
  287. new PlainTextMigrator(),
  288. MigrationTestData::PLAIN_TEXT_PAYLOAD_WITH_INVALID_URI,
  289. ],
  290. 'VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [
  291. new AegisMigrator(),
  292. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE,
  293. ],
  294. 'VALID_2FAS_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [
  295. new TwoFASMigrator(),
  296. MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE,
  297. ],
  298. 'VALID_2FAUTH_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE' => [
  299. new TwoFAuthMigrator(),
  300. MigrationTestData::VALID_2FAUTH_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_OTP_TYPE,
  301. ],
  302. ];
  303. }
  304. /**
  305. * @test
  306. *
  307. * @runInSeparateProcess
  308. *
  309. * @preserveGlobalState disabled
  310. */
  311. public function test_migrate_gauth_returns_fake_accounts()
  312. {
  313. $this->mock('alias:' . Base32::class, function (MockInterface $baseEncoder) {
  314. $baseEncoder->shouldReceive('encodeUpper')
  315. ->andThrow(new \Exception());
  316. });
  317. $migrator = new GoogleAuthMigrator();
  318. $accounts = $migrator->migrate(MigrationTestData::GOOGLE_AUTH_MIGRATION_URI);
  319. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  320. $this->assertCount(2, $accounts);
  321. // The returned collection could have non-linear index (because of possible blank lines
  322. // in the migration payload) so we do not use get() to retrieve items
  323. $this->assertEquals($this->fakeTwofaccount->id, $accounts->first()->id);
  324. $this->assertEquals($this->fakeTwofaccount->id, $accounts->last()->id);
  325. }
  326. /**
  327. * @test
  328. *
  329. * @dataProvider AegisWithIconMigrationProvider
  330. */
  331. public function test_migrate_aegis_payload_with_icon_sets_and_stores_the_icon($migration)
  332. {
  333. Storage::fake('icons');
  334. $migrator = new AegisMigrator();
  335. $accounts = $migrator->migrate($migration);
  336. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  337. $this->assertCount(1, $accounts);
  338. Storage::disk('icons')->assertExists($accounts->first()->icon);
  339. }
  340. /**
  341. * Provide data for TwoFAccount store tests
  342. */
  343. public function AegisWithIconMigrationProvider()
  344. {
  345. return [
  346. 'SVG' => [
  347. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_SVG_ICON,
  348. ],
  349. 'PNG' => [
  350. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_PNG_ICON,
  351. ],
  352. 'JPG' => [
  353. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_JPG_ICON,
  354. ],
  355. ];
  356. }
  357. /**
  358. * @test
  359. */
  360. public function test_migrate_aegis_payload_with_unsupported_icon_does_not_fail()
  361. {
  362. Storage::fake('icons');
  363. $migrator = new AegisMigrator();
  364. $accounts = $migrator->migrate(MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON);
  365. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  366. $this->assertCount(1, $accounts);
  367. $this->assertNull($this->fakeTwofaccount->icon);
  368. Storage::disk('icons')->assertDirectoryEmpty('/');
  369. }
  370. /**
  371. * @test
  372. *
  373. * @dataProvider TwoFAuthWithIconMigrationProvider
  374. */
  375. public function test_migrate_2fauth_payload_with_icon_sets_and_stores_the_icon($migration)
  376. {
  377. Storage::fake('icons');
  378. $migrator = new TwoFAuthMigrator();
  379. $accounts = $migrator->migrate($migration);
  380. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  381. $this->assertCount(1, $accounts);
  382. Storage::disk('icons')->assertExists($accounts->first()->icon);
  383. }
  384. /**
  385. * Provide data for TwoFAccount store tests
  386. */
  387. public function TwoFAuthWithIconMigrationProvider()
  388. {
  389. return [
  390. 'SVG' => [
  391. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_SVG_ICON,
  392. ],
  393. 'PNG' => [
  394. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_PNG_ICON,
  395. ],
  396. 'JPG' => [
  397. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_JPG_ICON,
  398. ],
  399. 'BMP' => [
  400. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_BMP_ICON,
  401. ],
  402. 'WEBP' => [
  403. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_WEBP_ICON,
  404. ],
  405. ];
  406. }
  407. /**
  408. * @test
  409. */
  410. public function test_migrate_2fauth_payload_with_unsupported_icon_does_not_fail()
  411. {
  412. Storage::fake('icons');
  413. $migrator = new TwoFAuthMigrator();
  414. $accounts = $migrator->migrate(MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON);
  415. $this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
  416. $this->assertCount(1, $accounts);
  417. $this->assertNull($this->fakeTwofaccount->icon);
  418. Storage::disk('icons')->assertDirectoryEmpty('/');
  419. }
  420. /**
  421. * @test
  422. *
  423. * @dataProvider factoryProvider
  424. */
  425. public function test_factory_returns_relevant_migrator($payload, $migratorClass)
  426. {
  427. $factory = new MigratorFactory();
  428. $migrator = $factory->create($payload);
  429. $this->assertInstanceOf($migratorClass, $migrator);
  430. }
  431. /**
  432. * Provide data for TwoFAccount store tests
  433. */
  434. public function factoryProvider()
  435. {
  436. return [
  437. 'VALID_PLAIN_TEXT_PAYLOAD' => [
  438. MigrationTestData::VALID_PLAIN_TEXT_PAYLOAD,
  439. PlainTextMigrator::class,
  440. ],
  441. 'VALID_AEGIS_JSON_MIGRATION_PAYLOAD' => [
  442. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD,
  443. AegisMigrator::class,
  444. ],
  445. 'VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON' => [
  446. MigrationTestData::VALID_AEGIS_JSON_MIGRATION_PAYLOAD_WITH_UNSUPPORTED_ICON,
  447. AegisMigrator::class,
  448. ],
  449. 'VALID_2FAS_MIGRATION_PAYLOAD' => [
  450. MigrationTestData::VALID_2FAS_MIGRATION_PAYLOAD,
  451. TwoFASMigrator::class,
  452. ],
  453. 'GOOGLE_AUTH_MIGRATION_URI' => [
  454. MigrationTestData::GOOGLE_AUTH_MIGRATION_URI,
  455. GoogleAuthMigrator::class,
  456. ],
  457. '2FAUTH_MIGRATION_URI' => [
  458. MigrationTestData::VALID_2FAUTH_JSON_MIGRATION_PAYLOAD,
  459. TwoFAuthMigrator::class,
  460. ],
  461. ];
  462. }
  463. /**
  464. * @test
  465. */
  466. public function test_factory_throw_UnsupportedMigrationException()
  467. {
  468. $this->expectException(UnsupportedMigrationException::class);
  469. $factory = new MigratorFactory();
  470. $migrator = $factory->create('not_a_valid_payload');
  471. }
  472. /**
  473. * @test
  474. *
  475. * @dataProvider encryptedMigrationDataProvider
  476. */
  477. public function test_factory_throw_EncryptedMigrationException($payload)
  478. {
  479. $this->expectException(EncryptedMigrationException::class);
  480. $factory = new MigratorFactory();
  481. $migrator = $factory->create($payload);
  482. }
  483. /**
  484. * Provide data for TwoFAccount store tests
  485. */
  486. public function encryptedMigrationDataProvider()
  487. {
  488. return [
  489. 'ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD' => [
  490. MigrationTestData::ENCRYPTED_AEGIS_JSON_MIGRATION_PAYLOAD,
  491. ],
  492. 'ENCRYPTED_2FAS_MIGRATION_PAYLOAD' => [
  493. MigrationTestData::ENCRYPTED_2FAS_MIGRATION_PAYLOAD,
  494. ],
  495. ];
  496. }
  497. protected function tearDown() : void
  498. {
  499. Mockery::close();
  500. }
  501. }