Skip to content

Commit

Permalink
Catching up to rename changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-constine-ttd committed Nov 20, 2024
1 parent a0a099c commit 07f4da8
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion conf/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"salts_metadata_path": "salts/metadata.json",
"services_metadata_path": "services/metadata.json",
"service_links_metadata_path": "service_links/metadata.json",
"s3_keys_metadata_path": "s3encryption_keys/metadata.json",
"cloud_encryption_keys_metadata_path": "s3encryption_keys/metadata.json",
"optout_metadata_path": null,
"optout_inmem_cache": false,
"enclave_platform": null,
Expand Down
2 changes: 1 addition & 1 deletion conf/docker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"salts_metadata_path": "/com.uid2.core/test/salts/metadata.json",
"services_metadata_path": "/com.uid2.core/test/services/metadata.json",
"service_links_metadata_path": "/com.uid2.core/test/service_links/metadata.json",
"s3_keys_metadata_path": "/com.uid2.core/test/s3encryption_keys/metadata.json",
"cloud_encryption_keys_metadata_path": "/com.uid2.core/test/s3encryption_keys/metadata.json",
"identity_token_expires_after_seconds": 3600,
"optout_metadata_path": null,
"optout_inmem_cache": false,
Expand Down
2 changes: 1 addition & 1 deletion conf/integ-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"optout_api_token": "test-operator-key",
"optout_api_uri": "http://localhost:8081/optout/replicate",
"salts_expired_shutdown_hours": 12,
"s3_keys_metadata_path": "http://localhost:8088/s3encryption_keys/retrieve",
"cloud_encryption_keys_metadata_path": "http://localhost:8088/s3encryption_keys/retrieve",
"operator_type": "public"
}
2 changes: 1 addition & 1 deletion conf/local-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"salts_metadata_path": "/com.uid2.core/test/salts/metadata.json",
"services_metadata_path": "/com.uid2.core/test/services/metadata.json",
"service_links_metadata_path": "/com.uid2.core/test/service_links/metadata.json",
"s3_keys_metadata_path":"/com.uid2.core/test/s3encryption_keys/metadata.json",
"cloud_encryption_keys_metadata_path":"/com.uid2.core/test/s3encryption_keys/metadata.json",
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
Expand Down
2 changes: 1 addition & 1 deletion conf/local-e2e-docker-private-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"keysets_metadata_path": "http://core:8088/key/keyset/refresh",
"keyset_keys_metadata_path": "http://core:8088/key/keyset-keys/refresh",
"salts_metadata_path": "http://core:8088/salt/refresh",
"s3_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"cloud_encryption_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
Expand Down
2 changes: 1 addition & 1 deletion conf/local-e2e-docker-public-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"salts_metadata_path": "http://core:8088/salt/refresh",
"services_metadata_path": "http://core:8088/services/refresh",
"service_links_metadata_path": "http://core:8088/service_links/refresh",
"s3_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"cloud_encryption_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
Expand Down
2 changes: 1 addition & 1 deletion conf/local-e2e-private-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"salts_metadata_path": "http://localhost:8088/salt/refresh",
"services_metadata_path": "http://localhost:8088/services/refresh",
"service_links_metadata_path": "http://localhost:8088/service_links/refresh",
"s3_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"cloud_encryption_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
Expand Down
2 changes: 1 addition & 1 deletion conf/local-e2e-public-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"salts_metadata_path": "http://localhost:8088/salt/refresh",
"services_metadata_path": "http://localhost:8088/services/refresh",
"service_links_metadata_path": "http://localhost:8088/service_links/refresh",
"s3_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"cloud_encryption_keys_metadata_path": "http://core:8088/s3encryption_keys/retrieve",
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
Expand Down
2 changes: 1 addition & 1 deletion conf/validator-latest-e2e-docker-public-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"salts_metadata_path": "http://core:8088/salt/refresh",
"services_metadata_path": "http://core:8088/services/refresh",
"service_links_metadata_path": "http://core:8088/service_links/refresh",
"s3_keys_metadata_path": "https://core:8088/s3encryption_keys/retrieve",
"cloud_encryption_keys_metadata_path": "https://core:8088/s3encryption_keys/retrieve",
"identity_token_expires_after_seconds": 3600,
"refresh_token_expires_after_seconds": 86400,
"refresh_identity_token_after_seconds": 900,
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/uid2/operator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.uid2.operator.monitoring.IStatsCollectorQueue;
import com.uid2.operator.monitoring.OperatorMetrics;
import com.uid2.operator.monitoring.StatsCollectorVerticle;
import com.uid2.operator.reader.RotatingS3KeyOperatorProvider;
import com.uid2.operator.reader.RotatingCloudEncryptionKeyApiProvider;
import com.uid2.operator.service.SecureLinkValidatorService;
import com.uid2.operator.service.ShutdownService;
import com.uid2.operator.vertx.Endpoints;
Expand Down Expand Up @@ -82,7 +82,7 @@ public class Main {
private IStatsCollectorQueue _statsCollectorQueue;
private RotatingServiceStore serviceProvider;
private RotatingServiceLinkStore serviceLinkProvider;
private RotatingS3KeyOperatorProvider s3KeyProvider;
private RotatingCloudEncryptionKeyApiProvider s3KeyProvider;

public Main(Vertx vertx, JsonObject config) throws Exception {
this.vertx = vertx;
Expand Down Expand Up @@ -134,8 +134,8 @@ public Main(Vertx vertx, JsonObject config) throws Exception {
this.fsOptOut = configureCloudOptOutStore();
}

String s3KeyMdPath = this.config.getString(Const.Config.S3keysMetadataPathProp);
this.s3KeyProvider = new RotatingS3KeyOperatorProvider(fsStores, new GlobalScope(new CloudPath(s3KeyMdPath)));
String s3KeyMdPath = this.config.getString(Const.Config.CloudEncryptionKeysMetadataPathProp);
this.s3KeyProvider = new RotatingCloudEncryptionKeyApiProvider(fsStores, new GlobalScope(new CloudPath(s3KeyMdPath)));
String sitesMdPath = this.config.getString(Const.Config.SitesMetadataPathProp);
String keypairMdPath = this.config.getString(Const.Config.ClientSideKeypairsMetadataPathProp);
this.clientSideKeypairProvider = new RotatingClientSideKeypairStore(fsStores, new GlobalScope(new CloudPath(keypairMdPath)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
package com.uid2.operator.reader;

import com.uid2.operator.reader.ApiStoreReader;
import com.uid2.shared.cloud.DownloadCloudStorage;
import com.uid2.shared.model.S3Key;
import com.uid2.shared.model.CloudEncryptionKey;
import com.uid2.shared.store.CloudPath;
import com.uid2.shared.store.parser.S3KeyParser;
import com.uid2.shared.store.reader.RotatingS3KeyProvider;
import com.uid2.shared.store.parser.CloudEncryptionKeyParser;
import com.uid2.shared.store.reader.RotatingCloudEncryptionKeyProvider;
import com.uid2.shared.store.scope.StoreScope;
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;

public class RotatingS3KeyOperatorProvider extends RotatingS3KeyProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(RotatingS3KeyOperatorProvider.class);
public class RotatingCloudEncryptionKeyApiProvider extends RotatingCloudEncryptionKeyProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(RotatingCloudEncryptionKeyApiProvider.class);

public ApiStoreReader<Map<Integer, S3Key>> apiStoreReader;
public ApiStoreReader<Map<Integer, CloudEncryptionKey>> apiStoreReader;

public RotatingS3KeyOperatorProvider(DownloadCloudStorage fileStreamProvider, StoreScope scope) {
public RotatingCloudEncryptionKeyApiProvider(DownloadCloudStorage fileStreamProvider, StoreScope scope) {
super(fileStreamProvider, scope);
this.apiStoreReader = new ApiStoreReader<>(fileStreamProvider, scope, new S3KeyParser(), "s3encryption_keys");
this.apiStoreReader = new ApiStoreReader<>(fileStreamProvider, scope, new CloudEncryptionKeyParser(), "s3encryption_keys");
}

@Override
Expand All @@ -41,8 +38,8 @@ public long loadContent(JsonObject metadata) throws Exception {
}

@Override
public Map<Integer, S3Key> getAll() {
Map<Integer, S3Key> keys = apiStoreReader.getSnapshot();
public Map<Integer, CloudEncryptionKey> getAll() {
Map<Integer, CloudEncryptionKey> keys = apiStoreReader.getSnapshot();
return keys != null ? keys : new HashMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.uid2.operator;

import com.uid2.operator.reader.ApiStoreReader;
import com.uid2.operator.reader.RotatingS3KeyOperatorProvider;
import com.uid2.operator.reader.RotatingCloudEncryptionKeyApiProvider;
import com.uid2.shared.cloud.DownloadCloudStorage;
import com.uid2.shared.model.S3Key;
import com.uid2.shared.model.CloudEncryptionKey;
import com.uid2.shared.store.CloudPath;
import com.uid2.shared.store.scope.StoreScope;
import io.vertx.core.json.JsonObject;
Expand All @@ -18,7 +18,7 @@
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

class RotatingS3KeyOperatorProviderTest {
class RotatingCloudEncryptionKeyApiProviderTest {

@Mock
private DownloadCloudStorage mockFileStreamProvider;
Expand All @@ -27,23 +27,23 @@ class RotatingS3KeyOperatorProviderTest {
private StoreScope mockScope;

@Mock
private ApiStoreReader<Map<Integer, S3Key>> mockApiStoreReader;
private ApiStoreReader<Map<Integer, CloudEncryptionKey>> mockApiStoreReader;

private RotatingS3KeyOperatorProvider rotatingS3KeyOperatorProvider;
private RotatingCloudEncryptionKeyApiProvider rotatingCloudEncryptionKeyApiProvider;

@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
rotatingS3KeyOperatorProvider = new RotatingS3KeyOperatorProvider(mockFileStreamProvider, mockScope);
rotatingS3KeyOperatorProvider.apiStoreReader = mockApiStoreReader;
rotatingCloudEncryptionKeyApiProvider = new RotatingCloudEncryptionKeyApiProvider(mockFileStreamProvider, mockScope);
rotatingCloudEncryptionKeyApiProvider.apiStoreReader = mockApiStoreReader;
}

@Test
void testGetMetadata() throws Exception {
JsonObject expectedMetadata = new JsonObject().put("version", 1L);
when(mockApiStoreReader.getMetadata()).thenReturn(expectedMetadata);

JsonObject metadata = rotatingS3KeyOperatorProvider.getMetadata();
JsonObject metadata = rotatingCloudEncryptionKeyApiProvider.getMetadata();
assertEquals(expectedMetadata, metadata);
verify(mockApiStoreReader).getMetadata();
}
Expand All @@ -53,7 +53,7 @@ void testGetMetadataPath() {
CloudPath expectedPath = new CloudPath("test/path");
when(mockApiStoreReader.getMetadataPath()).thenReturn(expectedPath);

CloudPath path = rotatingS3KeyOperatorProvider.getMetadataPath();
CloudPath path = rotatingCloudEncryptionKeyApiProvider.getMetadataPath();
assertEquals(expectedPath, path);
verify(mockApiStoreReader).getMetadataPath();
}
Expand All @@ -63,19 +63,19 @@ void testLoadContentWithMetadata() throws Exception {
JsonObject metadata = new JsonObject();
when(mockApiStoreReader.loadContent(metadata, "s3Keys")).thenReturn(1L);

long version = rotatingS3KeyOperatorProvider.loadContent(metadata);
long version = rotatingCloudEncryptionKeyApiProvider.loadContent(metadata);
assertEquals(1L, version);
verify(mockApiStoreReader).loadContent(metadata, "s3Keys");
}

@Test
void testGetAll() {
Map<Integer, S3Key> expectedKeys = new HashMap<>();
S3Key key = new S3Key(1, 123, 1687635529, 1687808329, "secret");
Map<Integer, CloudEncryptionKey> expectedKeys = new HashMap<>();
CloudEncryptionKey key = new CloudEncryptionKey(1, 123, 1687635529, 1687808329, "secret");
expectedKeys.put(1, key);
when(mockApiStoreReader.getSnapshot()).thenReturn(expectedKeys);

Map<Integer, S3Key> keys = rotatingS3KeyOperatorProvider.getAll();
Map<Integer, CloudEncryptionKey> keys = rotatingCloudEncryptionKeyApiProvider.getAll();
assertEquals(expectedKeys, keys);
verify(mockApiStoreReader).getSnapshot();
}
Expand All @@ -84,7 +84,7 @@ void testGetAll() {
void testGetAllWithNullSnapshot() {
when(mockApiStoreReader.getSnapshot()).thenReturn(null);

Map<Integer, S3Key> keys = rotatingS3KeyOperatorProvider.getAll();
Map<Integer, CloudEncryptionKey> keys = rotatingCloudEncryptionKeyApiProvider.getAll();
assertNotNull(keys);
assertTrue(keys.isEmpty());
verify(mockApiStoreReader).getSnapshot();
Expand All @@ -96,7 +96,7 @@ void testLoadContent() throws Exception {
when(mockApiStoreReader.getMetadata()).thenReturn(metadata);
when(mockApiStoreReader.loadContent(metadata, "s3Keys")).thenReturn(1L);

rotatingS3KeyOperatorProvider.loadContent();
rotatingCloudEncryptionKeyApiProvider.loadContent();
verify(mockApiStoreReader).getMetadata();
verify(mockApiStoreReader).loadContent(metadata, "s3Keys");
}
Expand Down

0 comments on commit 07f4da8

Please sign in to comment.