Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewind the keyFileStream before each read #29

Merged
merged 1 commit into from
Apr 3, 2016

Conversation

mcrumm
Copy link
Contributor

@mcrumm mcrumm commented Apr 2, 2016

When using either keyFile or keyFileStream to provide credentials to the ServiceBuilder, if the user's credentials expire between requests, an error will occur when trying to load credentials from the file stream, because the pointer is at the end of the stream.

Here's the output from the test prior to calling $keyFileStream->rewind() within the ServiceBuilder:

PHPUnit 5.1.3 by Sebastian Bergmann and contributors.

.....................EE.......................................... 65 / 96 ( 67%)
...............................                                   96 / 96 (100%)

Time: 250 ms, Memory: 16.77Mb

There were 2 errors:

1) Google\Cloud\Tests\RequestWrapperTest::testCredentialsFromKeyFileStreamCanBeReadMultipleTimes with data set #0 (array(Closure Object (...), Closure Object (...), '{"type":"authorized_user","cl..."abc"}'))
array_key_exists() expects parameter 2 to be array, null given

/Users/mike/Code/mcrumm/gcloud-php/vendor/google/auth/src/CredentialsLoader.php:118
/Users/mike/Code/mcrumm/gcloud-php/src/RequestWrapper.php:177
/Users/mike/Code/mcrumm/gcloud-php/tests/RequestWrapperTest.php:115

2) Google\Cloud\Tests\RequestWrapperTest::testCredentialsFromKeyFileStreamCanBeReadMultipleTimes with data set #1 (array(Closure Object (...), Closure Object (...), '/Users/mike/Code/mcrumm/gclou...e.json'))
array_key_exists() expects parameter 2 to be array, null given

/Users/mike/Code/mcrumm/gcloud-php/vendor/google/auth/src/CredentialsLoader.php:118
/Users/mike/Code/mcrumm/gcloud-php/src/RequestWrapper.php:177
/Users/mike/Code/mcrumm/gcloud-php/tests/RequestWrapperTest.php:115

FAILURES!
Tests: 96, Assertions: 115, Errors: 2.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 2, 2016
@dwsupplee
Copy link
Contributor

Thanks for this @mcrumm, Looks good to me.

@dwsupplee dwsupplee merged commit bda29bb into googleapis:master Apr 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants