-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: craman <[email protected]>
- Loading branch information
craman
committed
Jan 29, 2025
1 parent
3335c49
commit 3a79d5d
Showing
19 changed files
with
1,272 additions
and
2 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
...n/src/main/java/com/yahoo/athenz/common/server/notification/NotificationSlackMessage.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,42 @@ | ||
package com.yahoo.athenz.common.server.notification; | ||
|
||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
public class NotificationSlackMessage { | ||
|
||
private final String message; | ||
private final Set<String> recepients; | ||
|
||
public NotificationSlackMessage(String message, Set<String> recepients) { | ||
this.recepients = recepients; | ||
this.message = message; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
|
||
public Set<String> getRecepients() { | ||
return recepients; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
NotificationSlackMessage that = (NotificationSlackMessage) o; | ||
return Objects.equals(getMessage(), that.getMessage()) && | ||
Objects.equals(getRecepients(), that.getRecepients()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getMessage(), getRecepients()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...java/com/yahoo/athenz/common/server/notification/NotificationToSlackMessageConverter.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,26 @@ | ||
/* | ||
* Copyright The Athenz Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.yahoo.athenz.common.server.notification; | ||
|
||
public interface NotificationToSlackMessageConverter { | ||
/** | ||
* | ||
* @param notification object to be converted to slack message | ||
* @return The slack block content for the given Notification | ||
*/ | ||
NotificationSlackMessage getNotificationAsSlackMessage(Notification notification); | ||
} |
55 changes: 55 additions & 0 deletions
55
...c/test/java/com/yahoo/athenz/common/server/notification/NotificationSlackMessageTest.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,55 @@ | ||
/* | ||
* Copyright The Athenz Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.yahoo.athenz.common.server.notification; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import java.util.*; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
public class NotificationSlackMessageTest { | ||
|
||
@Test | ||
public void testNotificationSlackMessage() { | ||
|
||
Set<String> recipients = new HashSet<>(); | ||
recipients.add("[email protected]"); | ||
NotificationSlackMessage slackMessage1 = new NotificationSlackMessage("message1", recipients); | ||
NotificationSlackMessage slackMessage2 = new NotificationSlackMessage("message1", recipients); | ||
|
||
assertEquals(slackMessage1.hashCode(), slackMessage2.hashCode()); | ||
assertEquals(slackMessage1.getMessage(), "message1"); | ||
assertEquals(slackMessage1.getRecepients(), recipients); | ||
|
||
assertEquals(slackMessage1, slackMessage2); | ||
assertEquals(slackMessage1, slackMessage1); | ||
|
||
assertFalse(slackMessage1.equals(null)); | ||
|
||
slackMessage2 = new NotificationSlackMessage("message2", recipients); | ||
assertNotEquals(slackMessage1, slackMessage2); | ||
|
||
slackMessage2 = new NotificationSlackMessage("message1", recipients); | ||
assertEquals(slackMessage1, slackMessage2); | ||
|
||
Set<String> recipients2 = new HashSet<>(); | ||
recipients2.add("slack-channel"); | ||
slackMessage2 = new NotificationSlackMessage("message1", recipients2); | ||
assertNotEquals(slackMessage1, slackMessage2); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Athenz Server Notification Implementation using Slack | ||
============================================================= | ||
|
||
## License | ||
|
||
Copyright The Athenz Authors | ||
|
||
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright The Athenz Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.yahoo.athenz</groupId> | ||
<artifactId>athenz</artifactId> | ||
<version>1.12.10-SNAPSHOT</version> | ||
<relativePath>../../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>athenz-server-notification-slack</artifactId> | ||
<name>athenz-server-notification-slack</name> | ||
<description>Athenz Server Notification Implementation using Slack</description> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<code.coverage.min>0.96</code.coverage.min> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.yahoo.athenz</groupId> | ||
<artifactId>athenz-server-common</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.yahoo.athenz</groupId> | ||
<artifactId>athenz-auth-core</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcprov-jdk18on</artifactId> | ||
<version>${bouncycastle.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcpkix-jdk18on</artifactId> | ||
<version>${bouncycastle.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcutil-jdk18on</artifactId> | ||
<version>${bouncycastle.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.protobuf</groupId> | ||
<artifactId>protobuf-java</artifactId> | ||
<version>${protobuf.java.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>${jackson-core.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>${jackson-databind.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${slf4j.server.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>${logback.server.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.slack.api</groupId> | ||
<artifactId>slack-api-client</artifactId> | ||
<version>${slack.client.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Oops, something went wrong.