This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1002 from zalando/aruha-2123-audit-log
audit log
- Loading branch information
Showing
47 changed files
with
869 additions
and
168 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/acceptance-test/java/org/zalando/nakadi/webservice/AuditLogAT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.zalando.nakadi.webservice; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.junit.Test; | ||
import org.zalando.nakadi.domain.Subscription; | ||
import org.zalando.nakadi.domain.SubscriptionBase; | ||
import org.zalando.nakadi.utils.RandomSubscriptionBuilder; | ||
import org.zalando.nakadi.webservice.utils.TestStreamingClient; | ||
|
||
import java.io.IOException; | ||
|
||
import static com.jayway.restassured.RestAssured.given; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.core.IsEqual.equalTo; | ||
import static org.zalando.nakadi.domain.SubscriptionBase.InitialPosition.END; | ||
import static org.zalando.nakadi.utils.TestUtils.waitFor; | ||
import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createEventType; | ||
import static org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription; | ||
|
||
public class AuditLogAT extends BaseAT { | ||
|
||
private static final String AUDIT_LOG_ET = "nakadi.audit.log"; | ||
|
||
@Test | ||
public void testAuditLogEventTypeIsCreated() { | ||
given() | ||
.get("/event-types/" + AUDIT_LOG_ET) | ||
.then() | ||
.statusCode(HttpStatus.SC_OK) | ||
.body("name", equalTo("nakadi.audit.log")) | ||
.body("owning_application", equalTo("stups_nakadi")); | ||
} | ||
|
||
@Test(timeout = 10000L) | ||
public void testAuditLogEventIsSent() throws IOException, InterruptedException { | ||
// subscribe to audit log | ||
final SubscriptionBase subscriptionBase = RandomSubscriptionBuilder.builder() | ||
.withEventType(AUDIT_LOG_ET) | ||
.withStartFrom(END) | ||
.buildSubscriptionBase(); | ||
final Subscription subscription = createSubscription(subscriptionBase); | ||
final TestStreamingClient client = new TestStreamingClient(URL, subscription.getId(), "batch_limit=1"); | ||
client.start(); | ||
|
||
// create event type | ||
createEventType(); | ||
|
||
// expect event to be posted to audit log as a reaction to event type creation | ||
waitFor(() -> assertThat(client.getBatches().size(), greaterThan(0))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.