Skip to content

Commit

Permalink
fix: use correct context name for Management API
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jul 8, 2024
1 parent 1396813 commit ac23b06
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public String name() {
@Override
public void initialize(ServiceExtensionContext context) {
webService.registerResource(CONTEXT_NAME, new ManagementApiController(store));

webService.registerResource(CONTEXT_NAME, new AuthenticationRequestFilter(registry, CONTEXT_NAME));
webService.registerResource(CONTEXT_NAME, new AuthenticationRequestFilter(registry, "management-api"));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EmptySource;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -113,6 +116,28 @@ void verifyManagementApi() throws IOException {
assertThat(result.get(BPN2)).isEqualTo(UPDATED_DID2);
}

@ParameterizedTest
@ValueSource(strings = "invalid-key")
@EmptySource
void verifyManagementApi_invalidAuthHeader(String invalidAuthHeader) {
seedServer(BPN1, DID1);
seedServer(BPN2, DID2);

given().baseUri(MANAGEMENT_ENDPOINT.toString())
.headers("x-api-key", invalidAuthHeader)
.contentType(JSON)
.then()
.statusCode(401);
}

@Test
void verifyManagementApi_missingAuthHeader() {
given().baseUri(MANAGEMENT_ENDPOINT.toString())
.contentType(JSON)
.then()
.statusCode(401);
}

@BeforeEach
void setUp() {
mapper = new ObjectMapper();
Expand Down

0 comments on commit ac23b06

Please sign in to comment.