use of org.jose4j.http.SimpleResponse in project kafka by apache.
the class RefreshingHttpsJwksTest method spyHttpsJwks.
/**
* We *spy* (not *mock*) the {@link HttpsJwks} instance because we want to have it
* _partially mocked_ to determine if it's calling its internal refresh method. We want to
* make sure it *doesn't* do that when we call our getJsonWebKeys() method on
* {@link RefreshingHttpsJwks}.
*/
private HttpsJwks spyHttpsJwks() {
HttpsJwks httpsJwks = new HttpsJwks("https://www.example.com");
SimpleResponse simpleResponse = new SimpleResponse() {
@Override
public int getStatusCode() {
return 200;
}
@Override
public String getStatusMessage() {
return "OK";
}
@Override
public Collection<String> getHeaderNames() {
return Collections.emptyList();
}
@Override
public List<String> getHeaderValues(String name) {
return Collections.emptyList();
}
@Override
public String getBody() {
return "{\"keys\": []}";
}
};
httpsJwks.setSimpleHttpGet(l -> simpleResponse);
return Mockito.spy(httpsJwks);
}
Aggregations