container.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. if (file_exists('/etc/alpine-release')) {
  3. if (version_compare(file_get_contents('/etc/alpine-release'), '3.8.0') < 0) {
  4. echo "Skipping test; Alpine < 3.8";
  5. exit(0);
  6. }
  7. }
  8. else if (file_exists('/etc/debian_version')) {
  9. if (version_compare(file_get_contents('/etc/debian_version'), '9.0') < 0) {
  10. echo "Skipping test; Debian < 9.0";
  11. exit(0);
  12. }
  13. }
  14. else {
  15. echo "FAIL: Unknown base image (neither /etc/alpine-release nor /etc/debian_version exists).\n";
  16. exit(1);
  17. }
  18. if (version_compare(PHP_VERSION, '7.2.0') < 0) {
  19. echo "Skipping test; PHP < 7.2";
  20. exit(0);
  21. }
  22. if (!defined('PASSWORD_ARGON2I')) {
  23. echo "FAIL: Constant PASSWORD_ARGON2I is not defined.\n";
  24. exit(1);
  25. }
  26. // Test vector generated using:
  27. // var_dump(password_hash('password', PASSWORD_ARGON2I, ['memory_cost' => 1<<3, 'time_cost' => 1, 'threads' => 1]));
  28. if (!password_verify('password', '$argon2i$v=19$m=8,t=1,p=1$RWxaRlZ0d1FTa3RSY1c1OQ$c7a/rJlPgvH9ItPi74UGuh0tdCBhpdDF7b/nA3QweX8')) {
  29. echo "FAIL: Failed to check test vector.\n";
  30. exit(1);
  31. }
  32. exit(0);