[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/tests/tests/auth/ -> misc.php (source)

   1  <?php
   2  
   3  /**
   4   * Misc test
   5   *
   6   * @group auth
   7   */
   8  class Misc_Auth_Tests extends PHPUnit\Framework\TestCase {
   9  
  10      protected function tearDown(): void {
  11          yourls_remove_all_filters( 'hmac_algo' );
  12      }
  13  
  14      public function test_yourls_skip_password_hashing_is_bool() {
  15          $this->assertIsBool(yourls_skip_password_hashing());
  16      }
  17  
  18      public function test_yourls_salt_return_string() {
  19          $this->assertIsString(yourls_salt(rand_str()));
  20      }
  21  
  22      public function test_yourls_hmac_algo_default() {
  23          $this->assertTrue( in_array(yourls_hmac_algo(), hash_hmac_algos()) );
  24      }
  25  
  26      public function test_yourls_hmac_algo_custom() {
  27          // get random hash_hmac_algo
  28          $rnd_algo = hash_hmac_algos()[mt_rand(0, count(hash_hmac_algos()) - 1)];
  29          yourls_add_filter('hmac_algo', function() use ($rnd_algo) {
  30              return $rnd_algo;
  31          } );
  32  
  33          // make sure it's the one we set
  34          $algo = yourls_hmac_algo();
  35          $this->assertSame($algo, $rnd_algo);
  36      }
  37  
  38      public function test_yourls_hmac_algo_non_existent() {
  39          $this->assertSame( yourls_hmac_algo('omgozh'), 'sha256' );
  40      }
  41  
  42  }


Generated: Wed Sep 28 05:10:02 2022 Cross-referenced by PHPXref 0.7.1