Skip to content

Commit

Permalink
Merge branch 'feature/14/14-participant-did' into feature/14/14-verif…
Browse files Browse the repository at this point in the history
…y-jws
  • Loading branch information
algattik committed Jun 29, 2022
2 parents 4284f1e + 830cc32 commit b537c9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ParticipantsCommandTest {
Participant participant2 = createParticipant();
String serverUrl = FAKER.internet().url();
String idsUrl = FAKER.internet().url();
String did = FAKER.internet().url();

RegistrationServiceCli app = new RegistrationServiceCli();
CommandLine cmd = new CommandLine(app);
Expand All @@ -59,7 +60,7 @@ void list() throws Exception {
when(app.registryApiClient.listParticipants())
.thenReturn(participants);

var exitCode = executeParticipantsAdd();
var exitCode = executeParticipantsList();
assertThat(exitCode).isEqualTo(0);
assertThat(serverUrl).isEqualTo(app.service);

Expand All @@ -81,16 +82,16 @@ void add() {

private int executeParticipantsAdd(String idsUrl) {
return cmd.execute(
"-d", "did:web:did-server:test-authority",
"-d", did,
"-k", "../rest-client/src/test/resources/private_p256.pem",
"-s", serverUrl,
"participants", "add",
"--ids-url", idsUrl);
}

private int executeParticipantsAdd() {
private int executeParticipantsList() {
return cmd.execute(
"-d", "did:web:did-server:test-authority",
"-d", did,
"-k", "../rest-client/src/test/resources/private_p256.pem",
"-s", serverUrl,
"participants", "list");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
@Path("/registry")
public class RegistrationApiController {

/**
* A IDS URL (this will be removed in https://github.com/agera-edc/MinimumViableDataspace/issues/174)
*/
private static final String TEMPORARY_IDS_URL_HEADER = "IdsUrl";

private final RegistrationService service;
Expand All @@ -68,7 +71,8 @@ public List<Participant> listParticipants() {
@ApiResponse(responseCode = "204", description = "No content")
@POST
public void addParticipant(
@HeaderParam(TEMPORARY_IDS_URL_HEADER) String idsUrl, @Context HttpHeaders headers) {
@HeaderParam(TEMPORARY_IDS_URL_HEADER) String idsUrl,
@Context HttpHeaders headers) {
var issuer = Objects.requireNonNull(headers.getHeaderString(CALLER_DID_HEADER));

service.addParticipant(issuer, idsUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,23 @@
@IntegrationTest
public class RegistrationApiClientTest {
static final String API_URL = "http://localhost:8182/authority";

static final Faker FAKER = new Faker();
static RegistryApi api;

String participantUrl = FAKER.internet().url();

@Test
void listParticipants() throws Exception {
@BeforeAll
static void setUpClass() throws Exception {
var privateKey = Path.of(PRIVATE_KEY_FILE);
var ecKey = (ECKey) ECKey.parseFromPEMEncodedObjects(Files.readString(privateKey));
var privateKeyWrapper = new EcPrivateKeyWrapper(ecKey);

var apiClient = ApiClientFactory.createApiClient(API_URL, DID_WEB, privateKeyWrapper);
var api = new RegistryApi(apiClient);
api = new RegistryApi(apiClient);
}

@Test
void listParticipants() {

assertThat(api.listParticipants())
.noneSatisfy(p -> assertThat(p.getUrl()).isEqualTo(participantUrl));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static org.eclipse.dataspaceconnector.registration.client.TestUtils.DID_WEB;
import static org.eclipse.dataspaceconnector.registration.client.TestUtils.PRIVATE_KEY_FILE;

@IntegrationTest
public class RegistrationApiCommandLineClientTest {
static final ObjectMapper MAPPER = new ObjectMapper();
static final Faker FAKER = new Faker();
Expand Down

0 comments on commit b537c9b

Please sign in to comment.