Skip to content

Commit

Permalink
Merge branch 'merge-upstream' into 'master'
Browse files Browse the repository at this point in the history
Merge upstream changes into master

See merge request torizon-platform/ota-tuf!334
  • Loading branch information
Ben Clouser committed Jun 27, 2024
2 parents 199b6c1 + ac9b04f commit 94bb724
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 81 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# initial scalafmt
0cd7f5aaffad9b813955d73cf0afee2be445782e

# Scala Steward: Reformat with scalafmt 3.8.2
1f7736d5edc8cf5fa9e680e0d3bfb017f4f04b9d
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.17
version = 3.8.2
runner.dialect = Scala213Source3
maxColumn = 100
indent.defnSite = 2
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ lazy val UnitTest = config("ut").extend(Test)

lazy val commonConfigs = Seq(ItTest, UnitTest)

val libatsVersion = "2.6.5-39-g05e9ed4-SNAPSHOT"
val libatsVersion = "2.6.6"

lazy val commonDeps = libraryDependencies ++= {
val scalaTestV = "3.2.18"
lazy val catsV = "2.10.0"
val scalaTestV = "3.2.19"
lazy val catsV = "2.12.0"
lazy val akkaHttpV = "10.5.2"
lazy val enumeratumV = "1.7.3"

Expand Down
2 changes: 1 addition & 1 deletion cli/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.5.6"

libraryDependencies += "io.circe" %% "circe-generic-extras" % "0.14.3"

libraryDependencies += "io.circe" %% "circe-literal" % "0.14.7" % Test
libraryDependencies += "io.circe" %% "circe-literal" % "0.14.8" % Test

fork := true
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,10 @@ object Schema {
def uniqueRepoIdRoleTypeIdx =
index("key_gen_requests_unique_idx", (repoId, roleType), unique = true)

override def * = (
id,
repoId,
status,
roleType,
keySize,
keyType,
threshold,
description
) <> ((KeyGenRequest.apply _).tupled, KeyGenRequest.unapply)
override def * = (id, repoId, status, roleType, keySize, keyType, threshold, description) <> (
(KeyGenRequest.apply _).tupled,
KeyGenRequest.unapply
)

}

Expand All @@ -66,14 +60,10 @@ object Schema {
def publicKey = column[TufKey]("public_key")
def privateKey = column[EncryptedColumn[TufPrivateKey]]("private_key")

override def * = (
id,
repoId,
roleType,
keyType,
publicKey,
privateKey.decrypted
) <> ((Key.apply _).tupled, Key.unapply)
override def * = (id, repoId, roleType, keyType, publicKey, privateKey.decrypted) <> (
(Key.apply _).tupled,
Key.unapply
)

}

Expand All @@ -88,15 +78,15 @@ object Schema {
def pk = primaryKey("pk_signed_root_roles", (repoId, version))

private def content_parsed = content <>
({ c => SignedPayload(c.signatures, c.signed.as[RootRole].valueOr(throw _), c.signed) },
(x: SignedPayload[RootRole]) => Some(JsonSignedPayload(x.signatures, x.json)))

override def * = (
repoId,
content_parsed,
expiresAt,
version
) <> ((SignedRootRole.apply _).tupled, SignedRootRole.unapply)
(
{ c => SignedPayload(c.signatures, c.signed.as[RootRole].valueOr(throw _), c.signed) },
(x: SignedPayload[RootRole]) => Some(JsonSignedPayload(x.signatures, x.json))
)

override def * = (repoId, content_parsed, expiresAt, version) <> (
(SignedRootRole.apply _).tupled,
SignedRootRole.unapply
)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import com.advancedtelematic.libtuf.crypt.CanonicalJson.*
import com.advancedtelematic.libtuf.data.ClientDataType.DelegatedRoleName
import com.advancedtelematic.libtuf.data.TufCodecs
import com.advancedtelematic.libtuf.data.TufDataType.TargetFormat.TargetFormat
import com.advancedtelematic.libtuf.data.TufDataType.{JsonSignedPayload, RoleType, TargetFormat, ValidKeyId}
import com.advancedtelematic.libtuf.data.TufDataType.{
JsonSignedPayload,
RoleType,
TargetFormat,
ValidKeyId
}
import com.advancedtelematic.libtuf_server.repo.server.Errors

import scala.util.Try
Expand Down
2 changes: 1 addition & 1 deletion libtuf/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ libraryDependencies ++= {
"com.softwaremill.sttp.client" %% "async-http-client-backend-future" % "2.3.0",
"org.slf4j" % "slf4j-api" % "1.7.16" % "provided",
"com.azure" % "azure-storage-blob" % "12.26.1",
"com.azure" % "azure-identity" % "1.12.2"
"com.azure" % "azure-identity" % "1.13.0"
)
}
2 changes: 1 addition & 1 deletion project/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libraryDependencies += "com.amazonaws" % "aws-java-sdk-s3" % "1.12.743"
libraryDependencies += "com.amazonaws" % "aws-java-sdk-s3" % "1.12.751"

libraryDependencies += "org.apache.commons" % "commons-compress" % "1.26.2"
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.advancedtelematic.tuf.reposerver.data

import com.advancedtelematic.tuf.reposerver.data.RepoDataType.{AddDelegationFromRemoteRequest, AggregatedPackage, DelegationInfo, Package}
import com.advancedtelematic.tuf.reposerver.data.RepoDataType.{
AddDelegationFromRemoteRequest,
AggregatedPackage,
DelegationInfo,
Package
}
import com.advancedtelematic.libtuf.data.ClientCodecs.*
import com.advancedtelematic.libats.codecs.CirceRefined.*
import com.advancedtelematic.libats.http.HttpCodecs.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ protected[db] class DelegationRepository()(implicit db: Database, ec: ExecutionC
Schema.delegations.filter(_.repoId === repoId).result
}


def persistAll(repoId: RepoId,
roleName: DelegatedRoleName,
content: JsonSignedPayload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ object Schema {

def pk = primaryKey("delegated_items_pk", (repoId, roleName, filename))

override def * = (
repoId,
filename,
roleName,
checksum,
length,
custom
) <> ((DelegatedTargetItem.apply _).tupled, DelegatedTargetItem.unapply)
override def * = (repoId, filename, roleName, checksum, length, custom) <> (
(DelegatedTargetItem.apply _).tupled,
DelegatedTargetItem.unapply
)

}

Expand All @@ -65,15 +61,10 @@ object Schema {

def pk = primaryKey("target_items_pk", (repoId, filename))

override def * = (
repoId,
filename,
uri,
checksum,
length,
custom,
storageMethod
) <> ((TargetItem.apply _).tupled, TargetItem.unapply)
override def * = (repoId, filename, uri, checksum, length, custom, storageMethod) <> (
(TargetItem.apply _).tupled,
TargetItem.unapply
)

}

Expand All @@ -90,15 +81,10 @@ object Schema {

def pk = primaryKey("signed_role_pk", (repoId, roleType))

override def * = (
repoId,
roleType,
content,
checksum,
length,
version,
expiresAt
) <> ((DbSignedRole.apply _).tupled, DbSignedRole.unapply)
override def * = (repoId, roleType, content, checksum, length, version, expiresAt) <> (
(DbSignedRole.apply _).tupled,
DbSignedRole.unapply
)

}

Expand Down Expand Up @@ -153,15 +139,11 @@ object Schema {

def pk = primaryKey("delegations_pk", (repoId, roleName))

override def * = (
repoId,
roleName,
content,
remoteUri,
lastFetched,
remoteHeaders,
friendlyName
) <> ((DbDelegation.apply _).tupled, DbDelegation.unapply)
override def * =
(repoId, roleName, content, remoteUri, lastFetched, remoteHeaders, friendlyName) <> (
(DbDelegation.apply _).tupled,
DbDelegation.unapply
)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ class DelegationsManagement()(implicit val db: Database, val ec: ExecutionContex
validateDelegationMetadataSignatures(targetsRole, delegation, delegationMetadata)
.valueOr(err => throw Errors.PayloadSignatureInvalid(err))

val validatedDelegationsRole = validateDelegationTargetPaths(targetsRole, roleName, delegationMetadata)
.valueOr(err => throw Errors.InvalidDelegatedTarget(err))
val validatedDelegationsRole =
validateDelegationTargetPaths(targetsRole, roleName, delegationMetadata)
.valueOr(err => throw Errors.InvalidDelegatedTarget(err))

val items = validatedDelegationsRole.signed.targets.map { case (filename, clientTargetItem) =>

val checksums = clientTargetItem.hashes.map { case (method, hash) =>
Checksum(method, hash)
}

if(checksums.isEmpty)
if (checksums.isEmpty)
throw Errors.InvalidDelegatedTarget(NonEmptyList.of("targets checksum cannot be empty"))

DelegatedTargetItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import akka.http.scaladsl.server.{Directive, Directives}
import akka.http.scaladsl.unmarshalling.PredefinedFromStringUnmarshallers.CsvSeq
import com.advancedtelematic.libtuf.data.ClientDataType.TargetCustom
import com.advancedtelematic.libtuf.data.TufDataType.TargetFormat.TargetFormat
import com.advancedtelematic.libtuf.data.TufDataType.{HardwareIdentifier, TargetFormat, TargetName, TargetVersion}
import com.advancedtelematic.libtuf.data.TufDataType.{
HardwareIdentifier,
TargetFormat,
TargetName,
TargetVersion
}
import io.circe.*
import akka.http.scaladsl.unmarshalling.*
import akka.http.scaladsl.util.FastFuture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ object NamespaceRepoId {

def apply(namespaceValidation: NamespaceValidation, findNsRepoFn: Namespace => Future[RepoId]) =
namespaceValidation.extractor.flatMap(ns => UserRepoId(ns, findNsRepoFn))

}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ class RepoTargetsResourceSpec
status shouldBe StatusCodes.NoContent
}

Get(apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=asc")).namespaced ~> routes ~> check {
Get(
apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=asc")
).namespaced ~> routes ~> check {
status shouldBe StatusCodes.OK

val result = responseAs[PaginationResult[Package]]
Expand All @@ -262,7 +264,9 @@ class RepoTargetsResourceSpec
result.values.map(_.filename.value) shouldBe Seq("mypath/mytargetName", "zotherpackage")
}

Get(apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=desc")).namespaced ~> routes ~> check {
Get(
apiUriV2(s"user_repo/search?sortBy=filename&sortDirection=desc")
).namespaced ~> routes ~> check {
status shouldBe StatusCodes.OK

val result = responseAs[PaginationResult[Package]]
Expand Down Expand Up @@ -497,7 +501,9 @@ class RepoTargetsResourceSpec
status shouldBe StatusCodes.NoContent
}

Get(apiUriV2(s"user_repo/grouped-search?sortBy=name&sortDirection=asc")).namespaced ~> routes ~> check {
Get(
apiUriV2(s"user_repo/grouped-search?sortBy=name&sortDirection=asc")
).namespaced ~> routes ~> check {
status shouldBe StatusCodes.OK
val values = responseAs[PaginationResult[AggregatedPackage]].values
values should have size 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import akka.http.scaladsl.model.{HttpRequest, StatusCodes}
import akka.http.scaladsl.model.headers.RawHeader
import com.advancedtelematic.libats.data.DataType.Namespace
import com.advancedtelematic.libtuf.data.TufDataType.RepoId
import com.advancedtelematic.tuf.reposerver.util.NamespaceSpecOps.{NamespaceTag, Namespaced, withRandomNamepace}
import com.advancedtelematic.tuf.reposerver.util.NamespaceSpecOps.{
withRandomNamepace,
NamespaceTag,
Namespaced
}
import io.circe.Json
import org.scalactic.source.Position
import org.scalatest.Tag
Expand Down

0 comments on commit 94bb724

Please sign in to comment.