DynamicKey5Test.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. include "../src/DynamicKey5.php";
  3. include "TestTool.php";
  4. $appID = '970ca35de60c44645bbae8a215061b33';
  5. $appCertificate = '5cfd2fd1755d40ecb72977518be15d3b';
  6. $channelName = "7d72365eb983485397e3e3f9d460bdda";
  7. $ts = 1446455472;
  8. $randomInt = 58964981;
  9. $uid = 2882341273;
  10. $expiredTs = 1446455471;
  11. function testRecordingKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs)
  12. {
  13. $expected = "005AgAoADkyOUM5RTQ2MTg3QTAyMkJBQUIyNkI3QkYwMTg0MzhDNjc1Q0ZFMUEQAJcMo13mDERkW7roohUGGzOwKDdW9buDA68oN1YAAA==";
  14. $actual = generateRecordingKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs);
  15. assertEqual($expected, $actual);
  16. }
  17. function testMediaChannelKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs)
  18. {
  19. $expected = "005AQAoAEJERTJDRDdFNkZDNkU0ODYxNkYxQTYwOUVFNTM1M0U5ODNCQjFDNDQQAJcMo13mDERkW7roohUGGzOwKDdW9buDA68oN1YAAA==";
  20. $actual = generateMediaChannelKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs);
  21. assertEqual($expected, $actual);
  22. }
  23. function testInChannelPermission($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs)
  24. {
  25. global $NO_UPLOAD;
  26. $noUpload = "005BAAoADgyNEQxNDE4M0FGRDkyOEQ4REFFMUU1OTg5NTg2MzA3MTEyNjRGNzQQAJcMo13mDERkW7roohUGGzOwKDdW9buDA68oN1YBAAEAAQAw";
  27. $generatedNoUpload = generateInChannelPermissionKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs, $NO_UPLOAD);
  28. assertEqual($noUpload, $generatedNoUpload);
  29. global $AUDIO_VIDEO_UPLOAD;
  30. $audioVideoUpload = "005BAAoADJERDA3QThENTE2NzJGNjQwMzY5NTFBNzE0QkI5NTc0N0Q1QjZGQjMQAJcMo13mDERkW7roohUGGzOwKDdW9buDA68oN1YBAAEAAQAz";
  31. $generatedAudioVideoUpload = generateInChannelPermissionKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs, $AUDIO_VIDEO_UPLOAD);
  32. assertEqual($audioVideoUpload, $generatedAudioVideoUpload);
  33. }
  34. testRecordingKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs);
  35. testMediaChannelKey($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs);
  36. testInChannelPermission($appID, $appCertificate, $channelName, $ts, $randomInt, $uid, $expiredTs);
  37. ?>