Skip to content

Commit

Permalink
Merge pull request #33 from toolsplus/feature/connect-on-forge
Browse files Browse the repository at this point in the history
Connect on Forge
  • Loading branch information
tbinna authored Jan 11, 2024
2 parents 9340c10 + e479808 commit fa3bb20
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object Dependencies {
}

object Version {
val atlassianConnectPlay = "0.5.0"
val atlassianConnectPlay = "0.6.0"
val playSlick = "5.1.0"
val scalaTestPlusPlay = "5.1.0"
val scalaCheck = "1.14.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ class SlickAtlassianHostRepositoryIt
}
}

"find the inserted host by installation id" in new AtlassianHostFixture {
withEvolutions {
await {
hostRepo.save(host)
}

await {
hostRepo.findByInstallationId(host.installationId.get)
} mustBe Some(host)
}
}

}

"saving the same Atlassian hosts twice" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ trait AtlassianHostFixture extends AtlassianHostGen {
"a890cfe7-3518-3920-b0b5-6fa412a7f3d4",
"io.toolsplus.atlassian.connect.play.scala.seed",
None,
Some("ari:cloud:ecosystem::installation/e786c5a3-819e-43cd-9cc9-d38a470a5df6"),
"LkbauUXN71J8jxRi9Nbf+8dwGtXxqta+Fu6k86aF+0IIzxkZ/GlggElYVoCqQg",
"https://example.atlassian.net",
"https://example.atlassian.net",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ trait AtlassianHostGen {
key <- alphaStr
clientKey <- clientKeyGen
oauthClientId <- option(alphaNumStr)
installationId <- option(alphaNumStr)
sharedSecret <- alphaNumStr.suchThat(s => s.length >= 32 && s.nonEmpty)
baseUrl <- alphaStr
productType <- productTypeGen
Expand All @@ -29,6 +30,7 @@ trait AtlassianHostGen {
clientKey,
key,
oauthClientId,
installationId,
sharedSecret,
baseUrl,
baseUrl,
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/evolutions/default/1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CREATE TABLE atlassian_host
client_key VARCHAR PRIMARY KEY NOT NULL,
key VARCHAR NOT NULL,
oauth_client_id VARCHAR,
installation_id VARCHAR,
shared_secret VARCHAR NOT NULL,
base_url VARCHAR NOT NULL,
display_url VARCHAR NOT NULL,
Expand All @@ -19,6 +20,8 @@ CREATE UNIQUE INDEX uq_ac_host_client_key
ON atlassian_host (client_key);
CREATE INDEX uq_ac_host_base_url
ON atlassian_host (base_url);
CREATE INDEX uq_ac_host_installation_id
ON atlassian_host (installation_id);

# --- !Downs
DROP TABLE atlassian_host;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class SlickAtlassianHostRepository @Inject()(
def findByClientKey(clientKey: ClientKey): Future[Option[AtlassianHost]] =
db.run(hosts.filter(_.clientKey === clientKey).result.headOption)

def findByInstallationId(installationId: String): Future[Option[AtlassianHost]] =
db.run(hosts.filter(_.installationId === installationId).result.headOption)

/** Saves the given Atlassian host by inserting it if it does not exist or
* updating an existing record if it's already present.
*
Expand Down Expand Up @@ -55,6 +58,7 @@ private[slick] trait AtlassianHostTable {
val clientKey = column[ClientKey]("client_key", O.PrimaryKey)
val key = column[String]("key", NotNull)
val oauthClientId = column[Option[String]]("oauth_client_id")
val installationId = column[Option[String]]("installation_id")
val sharedSecret = column[String]("shared_secret", NotNull)
val baseUrl = column[String]("base_url", NotNull, SqlType("VARCHAR(512)"))
val displayUrl =
Expand All @@ -81,6 +85,7 @@ private[slick] trait AtlassianHostTable {
(clientKey,
key,
oauthClientId,
installationId,
sharedSecret,
baseUrl,
displayUrl,
Expand All @@ -95,6 +100,7 @@ private[slick] trait AtlassianHostTable {
private def toHost: (ClientKey,
String,
Option[String],
Option[String],
String,
String,
String,
Expand All @@ -111,6 +117,7 @@ private[slick] trait AtlassianHostTable {
(ClientKey,
String,
Option[String],
Option[String],
String,
String,
String,
Expand All @@ -126,6 +133,7 @@ private[slick] trait AtlassianHostTable {
host.clientKey,
host.key,
host.oauthClientId,
host.installationId,
host.sharedSecret,
host.baseUrl,
host.displayUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ class SlickAtlassianHostRepositorySpec
} mustBe Some(host)
}
}

"find the inserted host by installation id" in new AtlassianHostFixture {
withEvolutions {
await {
hostRepo.save(host)
}

await {
hostRepo.findByInstallationId(host.installationId.get)
} mustBe Some(host)
}
}
}

"saving the same Atlassian hosts twice" should {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.toolsplus.atlassian.connect.play.slick.fixtures

import io.toolsplus.atlassian.connect.play.api.models.{AtlassianHost, DefaultAtlassianHost}
import io.toolsplus.atlassian.connect.play.api.models.DefaultAtlassianHost
import io.toolsplus.atlassian.connect.play.slick.generators.AtlassianHostGen

trait AtlassianHostFixture extends AtlassianHostGen {
val defaultHost: DefaultAtlassianHost = DefaultAtlassianHost(
"a890cfe7-3518-3920-b0b5-6fa412a7f3d4",
"io.toolsplus.atlassian.connect.play.scala.seed",
None,
Some("ari:cloud:ecosystem::installation/e786c5a3-819e-43cd-9cc9-d38a470a5df6"),
"LkbauUXN71J8jxRi9Nbf+8dwGtXxqta+Fu6k86aF+0IIzxkZ/GlggElYVoCqQg",
"https://example.atlassian.net",
"https://example.atlassian.net",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ trait AtlassianHostGen {
key <- alphaStr
clientKey <- clientKeyGen
oauthClientId <- option(alphaNumStr)
installationId <- option(alphaNumStr)
sharedSecret <- alphaNumStr.suchThat(s => s.length >= 32 && s.nonEmpty)
baseUrl <- alphaStr
productType <- productTypeGen
Expand All @@ -29,6 +30,7 @@ trait AtlassianHostGen {
clientKey,
key,
oauthClientId,
installationId,
sharedSecret,
baseUrl,
baseUrl,
Expand Down

0 comments on commit fa3bb20

Please sign in to comment.