Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
2,824 additions
and
1,857 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 |
---|---|---|
@@ -1 +1 @@ | ||
* @whiskeysierra @lukasniemeier-zalando @fatroom | ||
* @whiskeysierra @lukasniemeier-zalando @fatroom @Semernitskaya @dingxiangfei2009 @joyfolk @gpradeepkrishna |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.8 | ||
17.0 |
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
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
36 changes: 19 additions & 17 deletions
36
riptide-auth/src/test/java/org/zalando/riptide/auth/AuthorizationPluginTest.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 |
---|---|---|
@@ -1,63 +1,65 @@ | ||
package org.zalando.riptide.auth; | ||
|
||
import com.github.restdriver.clientdriver.ClientDriver; | ||
import com.github.restdriver.clientdriver.ClientDriverFactory; | ||
import lombok.SneakyThrows; | ||
import okhttp3.mockwebserver.MockWebServer; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.client.SimpleClientHttpRequestFactory; | ||
import org.zalando.riptide.Http; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
|
||
import static com.github.restdriver.clientdriver.RestClientDriver.giveEmptyResponse; | ||
import static com.github.restdriver.clientdriver.RestClientDriver.onRequestTo; | ||
import static java.util.concurrent.Executors.newSingleThreadExecutor; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.springframework.http.HttpMethod.GET; | ||
import static org.zalando.riptide.PassRoute.pass; | ||
import static org.zalando.riptide.auth.MockWebServerUtil.emptyMockResponse; | ||
import static org.zalando.riptide.auth.MockWebServerUtil.getBaseUrl; | ||
import static org.zalando.riptide.auth.MockWebServerUtil.verify; | ||
|
||
final class AuthorizationPluginTest { | ||
|
||
private final ClientDriver driver = new ClientDriverFactory().createClientDriver(); | ||
private final MockWebServer server = new MockWebServer(); | ||
|
||
private final ExecutorService executor = newSingleThreadExecutor(); | ||
|
||
private final Http http = Http.builder() | ||
.executor(executor) | ||
.requestFactory(new SimpleClientHttpRequestFactory()) | ||
.baseUrl(driver.getBaseUrl()) | ||
.baseUrl(getBaseUrl(server)) | ||
.plugin(new AuthorizationPlugin(() -> "Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.e30.")) | ||
.build(); | ||
|
||
@SneakyThrows | ||
@AfterEach | ||
void tearDown() { | ||
executor.shutdown(); | ||
} | ||
|
||
@AfterEach | ||
void verify() { | ||
driver.verify(); | ||
server.shutdown(); | ||
} | ||
|
||
@Test | ||
void shouldFail() { | ||
driver.addExpectation( | ||
onRequestTo("/").withHeader("Authorization", "Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.e30."), | ||
giveEmptyResponse()); | ||
server.enqueue(emptyMockResponse()); | ||
|
||
http.get("/") | ||
.call(pass()) | ||
.join(); | ||
|
||
verify(server, 1, "/", GET.toString(), headers -> | ||
assertEquals("Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.e30.", headers.get("Authorization"))); | ||
} | ||
|
||
@Test | ||
void shouldNotOverwriteAuthorizationHeader() { | ||
driver.addExpectation( | ||
onRequestTo("/").withHeader("Authorization", "Basic dXNlcjpzZWNyZXQK"), | ||
giveEmptyResponse()); | ||
server.enqueue(emptyMockResponse()); | ||
|
||
http.get("/") | ||
.header("Authorization", "Basic dXNlcjpzZWNyZXQK") | ||
.call(pass()) | ||
.join(); | ||
|
||
verify(server, 1, "/", GET.toString(), headers -> | ||
assertEquals("Basic dXNlcjpzZWNyZXQK", headers.get("Authorization"))); | ||
} | ||
|
||
} |
Oops, something went wrong.