Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import org.cardanofoundation.signify.app.clienting.SignifyClient;
import org.cardanofoundation.signify.cesr.exceptions.LibsodiumException;
import org.cardanofoundation.signify.cesr.util.Utils;
import org.cardanofoundation.signify.generated.keria.model.Schema;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.http.HttpResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class Schemas {
Expand All @@ -30,7 +33,7 @@ public Schemas(SignifyClient client) {
* @throws InterruptedException if the operation is interrupted
* @throws LibsodiumException if a Sodium error occurs
*/
public Optional<Object> get(String said) throws IOException, InterruptedException, LibsodiumException {
public Optional<Schema> get(String said) throws IOException, InterruptedException, LibsodiumException {
String path = "/schema/" + said;
var method = "GET";
HttpResponse<String> response = this.client.fetch(path, method, null);
Expand All @@ -39,7 +42,7 @@ public Optional<Object> get(String said) throws IOException, InterruptedExceptio
return Optional.empty();
}

return Optional.of(Utils.fromJson(response.body(), Object.class));
return Optional.of(Utils.fromJson(response.body(), Schema.class));
}

/**
Expand All @@ -50,10 +53,10 @@ public Optional<Object> get(String said) throws IOException, InterruptedExceptio
* @throws InterruptedException if the operation is interrupted
* @throws LibsodiumException if a Sodium error occurs
*/
public Object list() throws IOException, InterruptedException, LibsodiumException {
public List<Schema> list() throws IOException, InterruptedException, LibsodiumException {
String path = "/schema";
String method = "GET";
HttpResponse<String> response = this.client.fetch(path, method, null);
return Utils.fromJson(response.body(), Object.class);
return Arrays.asList(Utils.fromJson(response.body(), Schema[].class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.security.DigestException;
import java.util.*;
import org.cardanofoundation.signify.generated.keria.model.Identifier;
import org.cardanofoundation.signify.generated.keria.model.Registry;

import static org.cardanofoundation.signify.cesr.util.CoreUtil.Versionage;

Expand All @@ -38,11 +39,11 @@ public Registries(SignifyClient client) {
* @throws InterruptedException if the operation is interrupted
* @throws LibsodiumException if a sodium exception occurs
*/
public Object list(String name) throws IOException, InterruptedException, LibsodiumException {
public List<Registry> list(String name) throws IOException, InterruptedException, LibsodiumException {
String path = "/identifiers/" + name + "/registries";
String method = "GET";
HttpResponse<String> response = this.client.fetch(path, method, null);
return Utils.fromJson(response.body(), Object.class);
return Arrays.asList(Utils.fromJson(response.body(), Registry[].class));
}

/**
Expand Down Expand Up @@ -155,14 +156,14 @@ private HttpResponse<String> createFromEvents(
* @throws InterruptedException if the operation is interrupted
* @throws LibsodiumException if a sodium exception occurs
*/
public Object rename(String name, String registryName, String newName) throws IOException, InterruptedException, LibsodiumException {
public Registry rename(String name, String registryName, String newName) throws IOException, InterruptedException, LibsodiumException {
String path = "/identifiers/" + name + "/registries/" + registryName;
String method = "PUT";

Map<String, Object> data = new LinkedHashMap<>();
data.put("name", newName);

HttpResponse<String> response = this.client.fetch(path, method, data);
return Utils.fromJson(response.body(), Object.class);
return Utils.fromJson(response.body(), Registry.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ public class CredentialState {
public enum EtEnum {
BIS(String.valueOf("bis")),

BRV(String.valueOf("brv"));
BRV(String.valueOf("brv")),

VCP(String.valueOf("vcp")),

ISS(String.valueOf("iss")),

REV(String.valueOf("rev"));

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.cardanofoundation.signify.e2e.utils.Retry;
import org.cardanofoundation.signify.e2e.utils.TestSteps;
import org.cardanofoundation.signify.e2e.utils.TestUtils;
import org.cardanofoundation.signify.generated.keria.model.Registry;
import org.cardanofoundation.signify.generated.keria.model.Schema;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -104,10 +106,9 @@ public void single_signature_credentials() throws Exception {
);
});

HashMap<String, Object> registrys = testSteps.step("Create registry", () -> {
Registry registrys = testSteps.step("Create registry", () -> {
String registryName = "vLEI-test-registry";
String updatedRegistryName = "vLEI-test-registry-1";
HashMap<String, Object> updateRegistry = new HashMap<>();

CreateRegistryArgs registryArgs = CreateRegistryArgs.builder().build();
registryArgs.setName(issuerAid.name);
Expand All @@ -119,51 +120,39 @@ public void single_signature_credentials() throws Exception {
throw new RuntimeException(e);
}
try {
Object registries = issuerClient.registries().list(issuerAid.name);
List<Map<String, Object>> registriesList = castObjectToListMap(registries);
HashMap<String, String> registry = new HashMap<>();
registry.put("name", registriesList.getFirst().get("name").toString());
registry.put("regk", registriesList.getFirst().get("regk").toString());
List<Registry> registriesList = issuerClient.registries().list(issuerAid.name);
assertEquals(1, registriesList.size());
assertEquals(registryName, registry.get("name"));
assertEquals(registryName, registriesList.getFirst().getName());
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}

try {
issuerClient.registries().rename(issuerAid.name, registryName, updatedRegistryName);
Object registries = issuerClient.registries().list(issuerAid.name);
List<Map<String, Object>> registriesList = castObjectToListMap(registries);
updateRegistry.put("name", registriesList.getFirst().get("name").toString());
updateRegistry.put("regk", registriesList.getFirst().get("regk").toString());
List<Registry> registriesList = issuerClient.registries().list(issuerAid.name);
assertEquals(1, registriesList.size());
assertEquals(updatedRegistryName, updateRegistry.get("name"));
assertEquals(updatedRegistryName, registriesList.getFirst().getName());
return registriesList.getFirst();
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
return updateRegistry;
});

testSteps.step("Issuer can get schemas", () -> {
try {
Object issuerQviSchema = issuerClient.schemas().get(QVI_SCHEMA_SAID).get();
LinkedHashMap<String, Object> issuerQviSchemaList = castObjectToLinkedHashMap(issuerQviSchema);
String issuerQviSchemaID = issuerQviSchemaList.get("$id").toString();
assertEquals(issuerQviSchemaID, QVI_SCHEMA_SAID);

Object issuerLeSchema = issuerClient.schemas().get(LE_SCHEMA_SAID).get();
LinkedHashMap<String, Object> issuerLeSchemaList = castObjectToLinkedHashMap(issuerLeSchema);
String issuerLeSchemaID = issuerLeSchemaList.get("$id").toString();
assertEquals(issuerLeSchemaID, LE_SCHEMA_SAID);
Schema issuerQviSchema = issuerClient.schemas().get(QVI_SCHEMA_SAID).get();
assertEquals(QVI_SCHEMA_SAID, issuerQviSchema.get$Id());

Schema issuerLeSchema = issuerClient.schemas().get(LE_SCHEMA_SAID).get();
assertEquals(LE_SCHEMA_SAID, issuerLeSchema.get$Id());
} catch (IOException | InterruptedException | LibsodiumException e) {
throw new RuntimeException(e);
}
});

testSteps.step("Holder can list schemas", () -> {
try {
Object holderSchemas = holderClient.schemas().list();
List<Map<String, Object>> holderSchemasList = castObjectToListMap(holderSchemas);
List<Schema> holderSchemasList = holderClient.schemas().list();
assertEquals(2, holderSchemasList.size());
} catch (IOException | InterruptedException | LibsodiumException e) {
throw new RuntimeException(e);
Expand All @@ -179,7 +168,7 @@ public void single_signature_credentials() throws Exception {
a.setAdditionalProperties(vcdata);

CredentialData cData = CredentialData.builder().build();
cData.setRi(registrys.get("regk").toString());
cData.setRi(registrys.getRegk());
cData.setS(QVI_SCHEMA_SAID);
cData.setA(a);

Expand Down Expand Up @@ -292,14 +281,14 @@ public void single_signature_credentials() throws Exception {
testSteps.step("Holder can get the credential status before or without holding", () -> {
Map<String, Object> state = (Map<String, Object>) Retry.retry(() -> {
try {
return holderClient.credentials().state(registrys.get("regk").toString(), qviCredentialId).get();
return holderClient.credentials().state(registrys.getRegk(), qviCredentialId).get();
} catch (IOException | InterruptedException | LibsodiumException e) {
throw new RuntimeException(e);
}
});

assertEquals(qviCredentialId, state.get("i"));
assertEquals(registrys.get("regk").toString(), state.get("ri"));
assertEquals(registrys.getRegk(), state.get("ri"));
assertEquals(CoreUtil.Ilks.ISS.getValue(), state.get("et"));
});

Expand Down Expand Up @@ -577,7 +566,7 @@ public void single_signature_credentials() throws Exception {
}
});

Map<String, Object> holderRegistry = testSteps.step("Holder create registry for LE credential", () -> {
Registry holderRegistry = testSteps.step("Holder create registry for LE credential", () -> {
String registryName = "vLEI-test-registry";
CreateRegistryArgs registryArgs = CreateRegistryArgs.builder().build();
registryArgs.setName(holderAid.name);
Expand All @@ -587,10 +576,9 @@ public void single_signature_credentials() throws Exception {
RegistryResult regResult = holderClient.registries().create(registryArgs);

waitOperation(holderClient, regResult.op());
Object registries = holderClient.registries().list(holderAid.name);
List<Map<String, Object>> registriesList = castObjectToListMap(registries);
List<Registry> registriesList = holderClient.registries().list(holderAid.name);

assertTrue(!registriesList.isEmpty());
assertFalse(registriesList.isEmpty());
return registriesList.getFirst();
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -630,7 +618,7 @@ public void single_signature_credentials() throws Exception {

CredentialData cData = CredentialData.builder().build();
cData.setA(cSubject);
cData.setRi(holderRegistry.get("regk").toString());
cData.setRi(holderRegistry.getRegk());
cData.setS(LE_SCHEMA_SAID);
cData.setR(sad);
cData.setE(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.cardanofoundation.signify.generated.keria.model.AidRecord;
import org.cardanofoundation.signify.generated.keria.model.GroupMember;
import org.cardanofoundation.signify.generated.keria.model.Identifier;
import org.cardanofoundation.signify.generated.keria.model.Registry;
import org.cardanofoundation.signify.core.Eventing;
import org.cardanofoundation.signify.e2e.utils.MultisigUtils.AcceptMultisigInceptArgs;
import org.cardanofoundation.signify.e2e.utils.MultisigUtils.StartMultisigInceptArgs;
Expand All @@ -42,7 +43,7 @@ public class MultisigHolderTest extends BaseIntegrationTest {
Identifier aid1, aid2, aid3;
OOBI oobi1, oobi2, oobi3;
String oobis1, oobis2, oobis3;
private List<HashMap<String, Object>> registryList;
private List<Registry> registryList;

ResolveEnv.EnvironmentConfig env = ResolveEnv.resolveEnvironment(null);
ArrayList<String> WITNESS_AIDS = new ArrayList<>(Arrays.asList(
Expand Down Expand Up @@ -404,10 +405,9 @@ void multisigHolderTest() throws Exception {

System.out.println("Issuer starting credential issuance to holder...");

Object registires = client3.registries().list("issuer");
List<HashMap<String, Object>> listRegistries = (List<HashMap<String, Object>>) registires;
Map<String, Object> registryMap = listRegistries.getFirst();
String regk = registryMap.get("regk").toString();
List<Registry> listRegistries = client3.registries().list("issuer");
Registry registry = listRegistries.getFirst();
String regk = registry.getRegk();

CredentialSubject subject = CredentialSubject.builder()
.i(holderAid.getPrefix())
Expand Down Expand Up @@ -502,7 +502,7 @@ public Identifier createAid(SignifyClient client, String name, List<String> wits
return aid;
}

public Object createRegistry(SignifyClient client, String name, String registryName) throws Exception {
public Registry createRegistry(SignifyClient client, String name, String registryName) throws Exception {
CreateRegistryArgs args = CreateRegistryArgs.builder()
.name(name)
.registryName(registryName)
Expand All @@ -512,13 +512,12 @@ public Object createRegistry(SignifyClient client, String name, String registryN
Object op = result.op();
waitOperation(client, op);

Object registries = client.registries().list(name);
registryList = (List<HashMap<String, Object>>) registries;
HashMap<String, Object> opResponseName = registryList.getFirst();
registryList = client.registries().list(name);
Registry registry = registryList.getFirst();

assertEquals(1, registryList.size());
assertEquals(registryName, opResponseName.get("name"));
return opResponseName;
assertEquals(registryName, registry.getName());
return registry;
}

public Object issueCredential(
Expand Down
Loading