ZF-2733: Zend_OpenId and Zend_Auth_Adapter_OpenId unit tests producing errors

Description

The errors all appear to be caused by inability to write to {{/tmp/root/openid/(consumer|provider)}}, which looks a bit strange because I did not run the tests as root:

The OpenID-related components are not alone in needing a place to store files when running unit tests, but automagically determining some operating-system-specific temporary directory seems weird because we are not using a service provider component to give us the location of this directory (e.g., {{Zend_Environment::getSystemTempDirectory()}}).

At least until something like this is available and well-tested, I recommend instead using the "{{_files}}" directory in which to write such files (e.g., {{/tests/Zend/OpenId/_files}}).

1) testAuthenticateLoginInvalid(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/library/Zend/OpenId/Consumer.php:100
/home/darby/framework/branch/release-1.5/library/Zend/Auth/Adapter/OpenId.php:220
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:81

2) testAuthenticateLoginValid(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:88

3) testSetIdentity(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:135

4) testSetStorage(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:183

5) testSetReturnTo(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:231

6) testSetRoot(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:279

7) testAuthenticateVerifyInvalid(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/library/Zend/OpenId/Consumer.php:100
/home/darby/framework/branch/release-1.5/library/Zend/Auth/Adapter/OpenId.php:254
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:329

8) testAuthenticateVerifyGetValid(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:336

9) testAuthenticateVerifyPostValid(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:362

10) testSetExtensions(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:389

11) testSetCheckImmediate(Zend_Auth_Adapter_OpenIdTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/Auth/Adapter/OpenId/OpenIdTest.php:423

...
26) testLogin(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:77

27) testCheck(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:228

28) testGetAssociation(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:278

29) testHttpRequest(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/library/Zend/OpenId/Consumer.php:100
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:302

30) testAssociate(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:385

31) testDiscovery(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:558

32) testVerify(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:726

33) testVerifyDumb(Zend_OpenId_ConsumerTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ConsumerTest.php:834

34) testGetAssociation(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:90

35) testGetAssociationByHandle(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:125

36) testGetAssociationExpiratin(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:144

37) testGetAssociationByHandleExpiration(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:158

38) testGetDiscoveryInfo(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:172

39) testGetDiscoveryInfoExpiration(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:207

40) testIsUniqueNonce(Zend_OpenId_Consumer_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/consumer
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Consumer/Storage/FileTest.php:220

41) testRegister(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:64

42) testHasUser(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:86

43) testLogin(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:110

44) testLogout(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:142

45) testLoggedInUser(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:165

46) testGetSiteRoot(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:188

47) testAllowSite(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:247

48) testDenySite(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:297

49) testDelSite(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:362

50) testGetTrustedSites(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:421

51) testGenSecret(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/library/Zend/OpenId/Provider.php:126
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:453

52) testAssociate(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:475

53) testCheckAuthentication(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:638

54) testRespondToConsumer(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:741

55) testCheckIdImmediate(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:862

56) testCheckIdSetup(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:1299

57) testHandle(Zend_OpenId_ProviderTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/library/Zend/OpenId/Provider.php:126
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/ProviderTest.php:1580

58) testGetAssociation(Zend_OpenId_Provider_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Provider/Storage/FileTest.php:88

59) testGetAssociationExpiratin(Zend_OpenId_Provider_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Provider/Storage/FileTest.php:122

60) testAddUser(Zend_OpenId_Provider_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Provider/Storage/FileTest.php:135

61) testHasUser(Zend_OpenId_Provider_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Provider/Storage/FileTest.php:150

62) testCheckUser(Zend_OpenId_Provider_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Provider/Storage/FileTest.php:164

63) testAddSite(Zend_OpenId_Provider_Storage_FileTest)
Zend_OpenId_Exception: Cannot access storage directory /tmp/root/openid/provider
/home/darby/framework/branch/release-1.5/tests/Zend/OpenId/Provider/Storage/FileTest.php:179

Comments

Reopening, please see comment on related issue [ZF-2626].

Good news is that I get no such problems on Linux, either with {{Zend_Auth_Adapter_OpenId_AllTests}} or {{Zend_OpenId_AllTests}}.

I get the same error + hanging/spinning behavior on Windows (PHP 5.1.4) with {{Zend_OpenId_AllTests}}:

$ phpunit --verbose Zend_OpenId_AllTests
PHPUnit 3.2.15 by Sebastian Bergmann.

Zend Framework - Zend_OpenId
 Zend_OpenId_ConsumerTest
 E

...does not complete

've fixed Windows file-system issues, however the "hang up" is not real. Some tests just spend significant time in math calculations. It may be a good idea to enable ext/php_gmp.dll in your php.ini, that will significantly improve Zend_OpenId performance.

Without GMP I now get no errors, hang-ups, or failures, but when I turn on GMP, I get the following failure from {{Zend_OpenId_AllTests}}:

There was 1 failure:

1) testVerify(Zend_OpenId_ConsumerTest)
Failed asserting that  is true.
c:\Documents and Settings\dfelton\My Documents\SVN Remote\Zend Framework\trunk\tests\Zend\OpenId\ConsumerTest.php:766

I noticed that it does run faster with GMP enabled. Is this documented as a recommendation? If not, a note should be added to the documentation that recommends use of GMP for performance.

I deleted all the contents of the various {{_files}} directories under {{trunk/tests/Zend/OpenId}}, and all of the {{Zend_OpenId_AllTests}} passed. I ran the suite again just to make sure it was repeatable, and it was. Marking this issue as resolved. :)

Dmitry, can you please merge revisions 8446 and 8456 to the release-1.5 branch, referring to the merged revision numbers and to this issue (ZF-2733) in your commit message? Please let me know if you have any questions or troubles with this. Thanks!