-
Notifications
You must be signed in to change notification settings - Fork 24
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
Hotfix: Change http status code for client 2.4.2 #145
Conversation
$statusCode = Http::STATUS_OK; | ||
} | ||
else { | ||
$statusCode = Http::STATUS_BAD_REQUEST; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this before the if condition?
$statusCode = Http::STATUS_BAD_REQUEST;
if (preg_match('/\bmirall\b.+2\.4\.2/i', $this->request->getHeader('User-Agent'))) {
$statusCode = Http::STATUS_OK;
}
This eases the flow of reading - and you could add a comment on top outlining that this is a fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you tell my, how to set a http user agent header in the unit test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently the request mock is created here:
$this->getMockBuilder('OCP\IRequest')->getMock(), |
make it a class field and you can work on it in the individual tests
@patrickjahns @phil-davis @individual-it can anyone tell me why acceptance tests are failing? |
Codecov Report
@@ Coverage Diff @@
## master #145 +/- ##
===========================================
+ Coverage 82.12% 82.2% +0.07%
- Complexity 199 200 +1
===========================================
Files 21 21
Lines 705 708 +3
===========================================
+ Hits 579 582 +3
Misses 126 126
Continue to review full report at Codecov.
|
Output from travis/ci
|
I restarted the first Travis job 974.1 for PHP 5.6 - that had hung for some reason and got the "no output for 10 minutes" message. |
Where did you see stuff about PHP 7.3 and PHP 7.4 ??? |
I saw that at the travis build log. |
Something went crazy in Travis! PHP 7.3beta1 came out last week, and so I guess PHP 7.4.0-dev does exist. But goodness knows what happened for Travis to use those. Anyway, CI passes. |
Will review soon. |
$_SERVER['PHP_AUTH_PW'] = null; | ||
|
||
$result = $this->controller->generateToken('refresh_token', null, null, $this->refreshToken->getToken()); | ||
$this->assertTrue($result instanceof JSONResponse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertInstanceOf
$this->assertNotEmpty($json->message_url); | ||
$this->assertEquals($this->authorizationSuccessfulMessageUrl, $json->message_url); | ||
$this->assertEquals(200, $result->getStatus()); | ||
$this->assertEquals(1, count($this->accessTokenMapper->findAll())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertCount
|
||
$result = $this->controller->generateToken('refresh_token', null, null, $this->refreshToken->getToken()); | ||
$this->assertTrue($result instanceof JSONResponse); | ||
$json = json_decode($result->render()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use getData - this gives you the array
Hotfix for #144
Problem
The 2.4.2 desktop client goes into an infinite loop when he gets a "invalid_grant" while refreshing his access code with response code 400. This puts very high loads on the webserver.
Hotfix
If he would get the same response with http status code 200, he would stop his infinite loop and open the webUI to re authorize.
Changes
I changed the http status code to 200 after checking for the 2.4.2 client in the request header.
All other clients get the 400 status code, as the Oauth Specs demand it. https://tools.ietf.org/html/rfc6749#section-5.2