Skip to content

Commit

Permalink
Renamed config endpoint and json file
Browse files Browse the repository at this point in the history
  • Loading branch information
BehnamMozafari committed Jan 7, 2025
1 parent 317c2df commit 4e042bf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/uid2/core/vertx/CoreVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private Router createRoutesSetup() {
router.get(Endpoints.OPERATORS_REFRESH.toString()).handler(auth.handle(attestationMiddleware.handle(this::handleOperatorRefresh), Role.OPTOUT_SERVICE));
router.get(Endpoints.PARTNERS_REFRESH.toString()).handler(auth.handle(attestationMiddleware.handle(this::handlePartnerRefresh), Role.OPTOUT_SERVICE));
router.get(Endpoints.OPS_HEALTHCHECK.toString()).handler(this::handleHealthCheck);
router.get(Endpoints.CONFIG.toString()).handler(this::handleGetConfig);
router.get(Endpoints.OPERATOR_CONFIG.toString()).handler(this::handleGetConfig);

if (Optional.ofNullable(ConfigStore.Global.getBoolean("enable_test_endpoints")).orElse(false)) {
router.route(Endpoints.ATTEST_GET_TOKEN.toString()).handler(auth.handle(this::handleTestGetAttestationToken, Role.OPERATOR));
Expand All @@ -203,11 +203,11 @@ private Router createRoutesSetup() {
}

private void handleGetConfig(RoutingContext rc) {
String dummyConfigPath = "conf/dummy-config.json";
String configPath = "conf/operator-config.json";

FileSystem fs = vertx.fileSystem();

fs.readFile(dummyConfigPath, ar -> {
fs.readFile(configPath, ar -> {
if (ar.succeeded()) {
String fileContent = ar.result().toString();
JsonObject configJson = new JsonObject(fileContent);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/uid2/core/vertx/Endpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum Endpoints {
SERVICE_LINKS_REFRESH("/service_links/refresh"),
OPERATORS_REFRESH("/operators/refresh"),
PARTNERS_REFRESH("/partners/refresh"),
CONFIG("/config");
OPERATOR_CONFIG("/operator/config");

private final String path;

Expand Down
14 changes: 3 additions & 11 deletions src/test/java/com/uid2/core/vertx/TestCoreVerticle.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.uid2.core.vertx;
import com.google.gson.JsonParser;
import com.uid2.core.model.ConfigStore;
import com.uid2.core.model.SecretStore;
import com.uid2.core.service.*;
Expand All @@ -10,19 +9,14 @@
import com.uid2.shared.attest.IAttestationTokenService;
import com.uid2.shared.attest.JwtService;
import com.uid2.shared.auth.*;
import com.uid2.shared.cloud.CloudStorageException;
import com.uid2.shared.cloud.ICloudStorage;
import com.uid2.shared.secure.AttestationException;
import com.uid2.shared.secure.AttestationFailure;
import com.uid2.shared.secure.AttestationResult;
import com.uid2.shared.secure.ICoreAttestationService;
import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider;
import io.vertx.config.ConfigRetriever;
import io.vertx.config.ConfigRetrieverOptions;
import io.vertx.config.ConfigStoreOptions;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
Expand All @@ -45,14 +39,12 @@

import javax.crypto.Cipher;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.SecureRandom;
import java.sql.SQLOutput;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -887,11 +879,11 @@ void keysRefreshSuccessNoHeaderVersion(Vertx vertx, VertxTestContext testContext
@Test
void getConfigSuccess(Vertx vertx, VertxTestContext testContext) throws Exception {
// Load expected config
String expectedConfigString = Files.readString(Paths.get("conf/dummy-config.json")).trim();
String expectedConfigString = Files.readString(Paths.get("conf/operator-config.json")).trim();
JsonObject expectedConfig = new JsonObject(expectedConfigString);

// Make HTTP Get request to /config endpoint
this.get(vertx, Endpoints.CONFIG.toString(), ar -> {
// Make HTTP Get request to operator config endpoint
this.get(vertx, Endpoints.OPERATOR_CONFIG.toString(), ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
System.out.println("Response: " + response.bodyAsString());
Expand Down

0 comments on commit 4e042bf

Please sign in to comment.