-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2022 Steve Phelps | ||
*/ | ||
|
||
import akka.util.ByteString | ||
import com.mesonomics.playhmacsignatures.EpochSeconds | ||
import org.scalatest.matchers.should | ||
import org.scalatest.wordspec.AnyWordSpecLike | ||
|
||
class ActionTests extends AnyWordSpecLike with should.Matchers { | ||
|
||
trait TestFixtures extends CommonFixtures { | ||
val timestamp: EpochSeconds = EpochSeconds(1000) | ||
val body: ByteString = ByteString("test-body") | ||
} | ||
|
||
"SlackSignatureVerifyAction" should { | ||
"compute the correct payload" in new TestFixtures { | ||
slackSignatureVerifyAction.payload( | ||
timestamp, | ||
body | ||
) shouldBe "v0:1000:test-body" | ||
} | ||
} | ||
} |
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,31 @@ | ||
/* | ||
* Copyright (c) 2022 Steve Phelps | ||
*/ | ||
|
||
import akka.actor.ActorSystem | ||
import akka.stream.Materializer | ||
import com.mesonomics.playhmacsignatures.{ | ||
SignatureVerifierService, | ||
SlackSignatureVerifyAction | ||
} | ||
import org.scalamock.scalatest.MockFactory | ||
import play.api.Configuration | ||
import play.api.mvc.BodyParsers | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
trait CommonFixtures extends MockFactory { | ||
val mockService: SignatureVerifierService = mock[SignatureVerifierService] | ||
val config: Configuration = Configuration( | ||
"slack.signingSecret" -> "test-secret" | ||
) | ||
implicit val system: ActorSystem = ActorSystem("ControllerTests") | ||
implicit val mat: Materializer = Materializer(system) | ||
val bp = new BodyParsers.Default() | ||
|
||
val slackSignatureVerifyAction = new SlackSignatureVerifyAction( | ||
bp, | ||
config, | ||
mockService | ||
) | ||
} |
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