-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRotatingClientKeyProviderTest.java
More file actions
35 lines (29 loc) · 1.37 KB
/
RotatingClientKeyProviderTest.java
File metadata and controls
35 lines (29 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.uid2.shared.auth;
import com.uid2.shared.cloud.EmbeddedResourceStorage;
import com.uid2.shared.store.CloudPath;
import com.uid2.shared.store.reader.RotatingClientKeyProvider;
import com.uid2.shared.store.scope.GlobalScope;
import io.vertx.core.json.JsonObject;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
public class RotatingClientKeyProviderTest {
@Test
public void testGetOldestClientKeyBySiteId() throws Exception {
RotatingClientKeyProvider provider = new RotatingClientKeyProvider(
new EmbeddedResourceStorage(RotatingClientKeyProviderTest.class),
new GlobalScope(new CloudPath("/com.uid2.shared/test/clients/metadata.json")));
JsonObject metadata = provider.getMetadata();
provider.loadContent(metadata);
assertEquals(1, provider.getVersion(metadata));
// a site that has multiple client keys
ClientKey expected = provider.getClientKey("trusted-partner-key");
assertNotNull(expected);
ClientKey actual = provider.getOldestClientKey(expected.getSiteId());
assertNotNull(actual);
assertThat(actual).isEqualTo(expected);
// a site that doesn't have client keys
actual = provider.getOldestClientKey(1234567890);
assertNull(actual);
}
}