-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch to accesstoken via query
- Loading branch information
Showing
7 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/test/java/com/gw2auth/oauth2/server/RequestMatchers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.gw2auth.oauth2.server; | ||
|
||
import org.hamcrest.core.IsAnything; | ||
import org.hamcrest.core.IsEqual; | ||
import org.springframework.http.client.ClientHttpRequest; | ||
import org.springframework.test.web.client.RequestMatcher; | ||
import org.springframework.web.util.UriComponents; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
import java.util.Optional; | ||
|
||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.queryParam; | ||
|
||
public final class RequestMatchers { | ||
|
||
public static RequestMatcher matchAuthorizedRequest() { | ||
return queryParam("access_token", new IsAnything<>()); | ||
} | ||
|
||
public static RequestMatcher matchAuthorizedRequest(String accessToken) { | ||
return queryParam("access_token", new IsEqual<>(accessToken)); | ||
} | ||
|
||
public static Optional<String> extractAccessToken(ClientHttpRequest request) { | ||
final String token = UriComponentsBuilder.fromUri(request.getURI()) | ||
.build() | ||
.getQueryParams() | ||
.getFirst("access_token"); | ||
|
||
return Optional.ofNullable(token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters