Skip to content

Commit

Permalink
#817 PsGithub more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Mar 1, 2018
1 parent b781578 commit 801feaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 5 additions & 9 deletions src/main/java/org/takes/facets/auth/social/PsGithub.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.json.JsonObject;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -169,7 +168,7 @@ private String token(final String home, final String code)
final String uri = new Href(this.github)
.path(PsGithub.LOGIN).path("oauth").path(PsGithub.ACCESS_TOKEN)
.toString();
final List<String> tokens = new JdkRequest(uri)
return new JdkRequest(uri)
.method("POST")
.header("Accept", "application/xml")
.body()
Expand All @@ -181,13 +180,10 @@ private String token(final String home, final String code)
.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.as(XmlResponse.class)
.xml().xpath("/OAuth/access_token/text()");
if (tokens.isEmpty()) {
throw new HttpException(
HttpURLConnection.HTTP_BAD_REQUEST, "No access token"
);
}
return tokens.get(0);
.assertXPath("/OAuth/access_token")
.xml()
.xpath("/OAuth/access_token/text()")
.get(0);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/org/takes/facets/auth/social/PsGithubTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.takes.HttpException;
import org.takes.Request;
import org.takes.Response;
import org.takes.Take;
Expand Down Expand Up @@ -96,8 +95,7 @@ public final class PsGithubTest {
*/
@Test
public void failsOnNoAccessToken() throws IOException {
this.thrown.expect(HttpException.class);
this.thrown.expectMessage("No access token");
this.thrown.expect(AssertionError.class);
this.performLogin(PsGithubTest.directiveWithoutAccessToken());
}

Expand Down

0 comments on commit 801feaa

Please sign in to comment.