Skip to content

Commit

Permalink
Merge pull request #620 from uptane/sync-upstream
Browse files Browse the repository at this point in the history
Sync toradex master to upstream master
  • Loading branch information
bclouser authored Nov 9, 2023
2 parents 295bece + 686a006 commit 8c98119
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
5 changes: 3 additions & 2 deletions deploy/ci_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -u

MARIADB_VERSION=10.11
docker rm --force ota_tuf-mariadb

# Some jobs don't behave, nuke them all
Expand All @@ -18,7 +19,7 @@ function start_mariadb() {
-e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_USER=ota_tuf \
-e MYSQL_PASSWORD=ota_tuf \
mariadb:10.2 \
mariadb:${MARIADB_VERSION} \
--character-set-server=utf8 --collation-server=utf8_unicode_ci \
--max_connections=1000
}
Expand All @@ -27,7 +28,7 @@ function mysqladmin_alive {
docker run \
--rm \
--link ota_tuf-mariadb \
mariadb:10.2 \
mariadb:${MARIADB_VERSION} \
mysqladmin ping --protocol=TCP -h ota_tuf-mariadb -P 3306 -u root -proot
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.advancedtelematic.libtuf_server.data

import com.advancedtelematic.libats.codecs.CirceCodecs._
import com.advancedtelematic.libtuf.data.TufCodecs._
import com.advancedtelematic.libats.codecs.CirceCodecs.*
import com.advancedtelematic.libtuf.data.TufCodecs.*
import com.advancedtelematic.libtuf.data.TufDataType.{KeyType, TargetFilename}
import io.circe.{Decoder, Encoder}
import io.circe.generic.semiauto.deriveEncoder
import io.circe.generic.semiauto.deriveDecoder

import java.time.Instant

object Requests {

case class CreateRepositoryRequest(keyType: KeyType)
Expand All @@ -28,4 +30,9 @@ object Requests {

implicit val filenameCommentEncoder: Encoder[FilenameComment] = deriveEncoder
implicit val filenameCommentDecoder: Decoder[FilenameComment] = deriveDecoder

case class ExpireNotBeforeRequest(expireAt: Instant)

implicit val refreshRequestEncoder: Encoder[ExpireNotBeforeRequest] = io.circe.generic.semiauto.deriveEncoder[ExpireNotBeforeRequest]
implicit val refreshRequestDecoder: Decoder[ExpireNotBeforeRequest] = io.circe.generic.semiauto.deriveDecoder[ExpireNotBeforeRequest]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import akka.http.scaladsl.marshalling.Marshal
import akka.http.scaladsl.model.*
import akka.http.scaladsl.model.Uri.Path.Slash
import akka.http.scaladsl.model.Uri.{Path, Query}
import akka.http.scaladsl.model.*
import akka.http.scaladsl.unmarshalling.FromEntityUnmarshaller
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
Expand All @@ -15,17 +16,20 @@ import com.advancedtelematic.libats.data.DataType.{Checksum, Namespace}
import com.advancedtelematic.libats.data.{ErrorCode, PaginationResult}
import com.advancedtelematic.libats.http.Errors.{RawError, RemoteServiceError}
import com.advancedtelematic.libats.http.ServiceHttpClientSupport
import com.advancedtelematic.libats.http.HttpCodecs.*
import com.advancedtelematic.libats.http.tracing.Tracing.ServerRequestTracing
import com.advancedtelematic.libats.http.tracing.TracingHttpClient
import com.advancedtelematic.libtuf.data.ClientCodecs.*
import com.advancedtelematic.libtuf.data.ClientDataType.{ClientTargetItem, DelegatedRoleName, Delegation, DelegationClientTargetItem, DelegationFriendlyName, RootRole, TargetsRole}
import com.advancedtelematic.libtuf.data.TufCodecs.*
import com.advancedtelematic.libtuf.data.TufDataType.TargetFormat.TargetFormat
import com.advancedtelematic.libtuf.data.TufDataType.{HardwareIdentifier, JsonSignedPayload, KeyType, RepoId, SignedPayload, TargetFilename, TargetName, TargetVersion}
import com.advancedtelematic.libtuf_server.data.Requests.{CommentRequest, CreateRepositoryRequest, FilenameComment, TargetComment}
import com.advancedtelematic.libtuf_server.data.Requests.{CommentRequest, CreateRepositoryRequest, ExpireNotBeforeRequest, FilenameComment, TargetComment}
import com.advancedtelematic.libtuf_server.repo.client.ReposerverClient.{DelegationInfo, KeysNotReady, NotFound, RootNotInKeyserver}
import io.circe.generic.semiauto.*
import io.circe.{Codec, Decoder, Encoder, Json}
import com.advancedtelematic.libats.codecs.CirceCodecs.*
import com.advancedtelematic.libtuf.data.ClientCodecs.*
import org.slf4j.LoggerFactory

import java.net.URI
Expand Down Expand Up @@ -104,6 +108,8 @@ trait ReposerverClient {
def fetchTargets(namespace: Namespace): Future[SignedPayload[TargetsRole]]

def setTargetComments(namespace: Namespace, targetFilename: TargetFilename, comment: String): Future[Unit]

def setTargetsMetadataExpiration(namespace: Namespace, expiry: Instant): Future[Unit]
def fetchSingleTargetComments(namespace: Namespace, targetFilename: TargetFilename): Future[FilenameComment]
def fetchTargetsComments(namespace: Namespace, targetNameContains: Option[String], offset: Option[Long], limit: Option[Long]): Future[PaginationResult[FilenameComment]]
def fetchTargetsCommentsByFilename(namespace: Namespace, filenames: Seq[TargetFilename]): Future[Seq[FilenameComment]]
Expand Down Expand Up @@ -298,6 +304,12 @@ class ReposerverHttpClient(reposerverUri: Uri, httpClient: HttpRequest => Future
execHttpUnmarshalledWithNamespace[Unit](namespace, req).ok
}

override def setTargetsMetadataExpiration(namespace: Namespace, expiry: Instant): Future[Unit] = {
val body = HttpEntity(ContentTypes.`application/json`, ExpireNotBeforeRequest(expiry).asJson.noSpaces)
val req = HttpRequest(HttpMethods.PUT, uri = apiUri(Path(s"user_repo/targets/expire/not-before")), entity = body)
execHttpUnmarshalledWithNamespace[Unit](namespace, req).ok
}

override def fetchTargetsComments(namespace: Namespace,
targetNameContains: Option[String],
offset: Option[Long],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,3 @@ class RepoResource(keyserverClient: KeyserverClient, namespaceValidation: Namesp
modifyRepoRoutes(repoId)
}
}

object ExpireNotBeforeRequest {
import io.circe.{Encoder, Decoder}

implicit val refreshRequestEncoder: Encoder[ExpireNotBeforeRequest] = io.circe.generic.semiauto.deriveEncoder[ExpireNotBeforeRequest]
implicit val refreshRequestDecoder: Decoder[ExpireNotBeforeRequest] = io.circe.generic.semiauto.deriveDecoder[ExpireNotBeforeRequest]
}


case class ExpireNotBeforeRequest(expireAt: Instant)

0 comments on commit 8c98119

Please sign in to comment.