mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-13 00:04:49 +00:00
Fix test and set up apiKey for package client servers
This commit is contained in:
parent
36142f4904
commit
a155475feb
@ -176,6 +176,8 @@ public class PackageClient {
|
||||
webAccessor.withToken(server.getToken());
|
||||
} else if (server.getAuthenticationMode() == HTTPAuthenticationMode.BASIC) {
|
||||
webAccessor.withBasicAuth(server.getUsername(), server.getPassword());
|
||||
} else if (server.getAuthenticationMode() == HTTPAuthenticationMode.APIKEY) {
|
||||
webAccessor.withApiKey(server.getApiKey());
|
||||
}
|
||||
HTTPResult res = webAccessor.get(source, accept);
|
||||
res.checkThrowException();
|
||||
|
@ -7,7 +7,6 @@ import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.hl7.fhir.utilities.http.HTTPAuthenticationMode;
|
||||
import org.hl7.fhir.utilities.http.SimpleHTTPClient;
|
||||
import org.hl7.fhir.utilities.settings.FhirSettings;
|
||||
import org.hl7.fhir.utilities.settings.ServerDetailsPOJO;
|
||||
|
||||
@ -27,10 +26,11 @@ public class PackageServer {
|
||||
serverType = PackageServerType.FHIR;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private String url;
|
||||
|
||||
@Getter
|
||||
private HTTPAuthenticationMode authenticationMode;
|
||||
private HTTPAuthenticationMode authenticationMode;
|
||||
|
||||
@Getter
|
||||
private PackageServerType serverType;
|
||||
@ -43,9 +43,11 @@ public class PackageServer {
|
||||
|
||||
@Getter
|
||||
private String token;
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private String apiKey;
|
||||
|
||||
|
||||
|
||||
public static final String PRIMARY_SERVER = "https://packages.fhir.org";
|
||||
public static final String SECONDARY_SERVER = "https://packages2.fhir.org/packages";
|
||||
@ -73,7 +75,9 @@ public class PackageServer {
|
||||
)
|
||||
.withUsername(pojo.getUsername())
|
||||
.withPassword(pojo.getPassword())
|
||||
.withToken(pojo.getToken());
|
||||
.withToken(pojo.getToken())
|
||||
.withApiKey(pojo.getApikey());
|
||||
|
||||
}
|
||||
|
||||
private static boolean isPackageServer(String serverType) {
|
||||
@ -129,6 +133,7 @@ public class PackageServer {
|
||||
packageServer.username = this.username;
|
||||
packageServer.password = this.password;
|
||||
packageServer.token = this.token;
|
||||
packageServer.apiKey = this.apiKey;
|
||||
return packageServer;
|
||||
}
|
||||
|
||||
@ -161,4 +166,10 @@ public class PackageServer {
|
||||
packageServer.token = token;
|
||||
return packageServer;
|
||||
}
|
||||
|
||||
public PackageServer withApiKey(String apiKey) {
|
||||
PackageServer packageServer = this.copy();
|
||||
packageServer.apiKey = apiKey;
|
||||
return packageServer;
|
||||
}
|
||||
}
|
@ -164,7 +164,7 @@ public class ManagedWebAccessAuthTests {
|
||||
return new ServerDetailsPOJO(
|
||||
server.url("").toString(),
|
||||
"basic",
|
||||
"dummyServerType",
|
||||
"fhir",
|
||||
DUMMY_USERNAME,
|
||||
DUMMY_PASSWORD,
|
||||
null, null);
|
||||
@ -183,7 +183,7 @@ public void testTokenAuthFromSettings() throws IOException, InterruptedException
|
||||
return new ServerDetailsPOJO(
|
||||
server.url("").toString(),
|
||||
"token",
|
||||
"dummyServerType",
|
||||
"fhir",
|
||||
null,
|
||||
null,
|
||||
DUMMY_TOKEN, null);
|
||||
@ -202,7 +202,7 @@ public void testTokenAuthFromSettings() throws IOException, InterruptedException
|
||||
return new ServerDetailsPOJO(
|
||||
server.url("").toString(),
|
||||
"apikey",
|
||||
"dummyServerType",
|
||||
"fhir",
|
||||
null,
|
||||
null,
|
||||
null, DUMMY_API_KEY);
|
||||
|
Loading…
x
Reference in New Issue
Block a user