From 43d66a8dfdf9d3dfec0aa837f9d59683267c3227 Mon Sep 17 00:00:00 2001 From: cyberone Date: Fri, 1 May 2015 16:26:12 +0600 Subject: [PATCH 1/3] Fix of #229 --- .../java/org/takes/facets/auth/social/PsGithub.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/takes/facets/auth/social/PsGithub.java b/src/main/java/org/takes/facets/auth/social/PsGithub.java index 9ac012abf..0a27bfaf6 100644 --- a/src/main/java/org/takes/facets/auth/social/PsGithub.java +++ b/src/main/java/org/takes/facets/auth/social/PsGithub.java @@ -124,14 +124,16 @@ private String token(final String home, final String code) throws IOException { // @checkstyle LineLength (1 line) final String uri = new Href("https://github.com/login/oauth/access_token") - .with("client_id", this.app) - .with("redirect_uri", home) - .with("client_secret", this.key) - .with("code", code) .toString(); return new JdkRequest(uri) .method("POST") .header("Accept", "application/xml") + .body() + .formParam("client_id", this.app) + .formParam("redirect_uri", home) + .formParam("client_secret", this.key) + .formParam("code", code) + .back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) From f0c3c6045baf07322da59e1f56a262e11440f6fa Mon Sep 17 00:00:00 2001 From: cyberone Date: Fri, 1 May 2015 19:07:12 +0600 Subject: [PATCH 2/3] Added puzzle --- src/main/java/org/takes/facets/auth/social/PsGithub.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/takes/facets/auth/social/PsGithub.java b/src/main/java/org/takes/facets/auth/social/PsGithub.java index 0a27bfaf6..234f3715c 100644 --- a/src/main/java/org/takes/facets/auth/social/PsGithub.java +++ b/src/main/java/org/takes/facets/auth/social/PsGithub.java @@ -51,6 +51,8 @@ * @version $Id$ * @since 0.1 * @checkstyle MultipleStringLiteralsCheck (500 lines) + * @todo #229: PsGithubTest should check that POST request arguments are + * passed as parameters at request body, not at head. */ @EqualsAndHashCode(of = { "app", "key" }) public final class PsGithub implements Pass { From 7e31b1503cfbf4646664a1da7444f1f1a6eeb8ad Mon Sep 17 00:00:00 2001 From: cyberone Date: Fri, 1 May 2015 19:20:39 +0600 Subject: [PATCH 3/3] Fixed puzzle --- src/main/java/org/takes/facets/auth/social/PsGithub.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/takes/facets/auth/social/PsGithub.java b/src/main/java/org/takes/facets/auth/social/PsGithub.java index 234f3715c..b409191b9 100644 --- a/src/main/java/org/takes/facets/auth/social/PsGithub.java +++ b/src/main/java/org/takes/facets/auth/social/PsGithub.java @@ -51,8 +51,9 @@ * @version $Id$ * @since 0.1 * @checkstyle MultipleStringLiteralsCheck (500 lines) - * @todo #229: PsGithubTest should check that POST request arguments are - * passed as parameters at request body, not at head. + * @todo #229:30min There is currently no unit test in PsGithubTest that + * checks that the request parameters are passed to the request body, + * instead of the URI. Let's add this test. */ @EqualsAndHashCode(of = { "app", "key" }) public final class PsGithub implements Pass {