FpaTokenBuilderTest.php 996 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once "../src/AccessToken2.php";
  3. require_once "../src/FpaTokenBuilder.php";
  4. class FpaTokenBuilderTest
  5. {
  6. public $appId = "970CA35de60c44645bbae8a215061b33";
  7. public $appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
  8. public $expire = 24 * 3600;
  9. public function run()
  10. {
  11. $this->test_buildToken();
  12. }
  13. public function test_buildToken()
  14. {
  15. $token = FpaTokenBuilder::buildToken($this->appId, $this->appCertificate);
  16. $accessToken = new AccessToken2();
  17. $accessToken->parse($token);
  18. Util::assertEqual($this->appId, $accessToken->appId);
  19. Util::assertEqual($this->expire, $accessToken->expire);
  20. Util::assertEqual(ServiceFpa::SERVICE_TYPE, $accessToken->services[ServiceFpa::SERVICE_TYPE]->type);
  21. Util::assertEqual(0, $accessToken->services[ServiceFpa::SERVICE_TYPE]->privileges[ServiceFpa::PRIVILEGE_LOGIN]);
  22. }
  23. }
  24. $fpaTokenBuilderTest = new FpaTokenBuilderTest();
  25. $fpaTokenBuilderTest->run();