-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Options for setting the expiration date when signing
Signed-off-by: Jochen Schneider <[email protected]>
- Loading branch information
Jochen Schneider
committed
Aug 8, 2019
1 parent
89ec974
commit 6b7ac68
Showing
10 changed files
with
151 additions
and
41 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
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
55 changes: 55 additions & 0 deletions
55
cli/src/test/scala/com/advancedtelematic/tuf/cli/CommandHandlerExpirationDateSpec.scala
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 @@ | ||
package com.advancedtelematic.tuf.cli | ||
|
||
import java.time.{Instant, Period} | ||
|
||
import com.advancedtelematic.tuf.cli.Errors.PastDate | ||
import org.scalatest.{FunSuite, Matchers} | ||
|
||
class CommandHandlerExpirationDateSpec extends FunSuite with Matchers { | ||
val now = Instant.EPOCH | ||
val oneDay = Period.ofDays(1) | ||
val inADay = now.plus(oneDay) | ||
|
||
// the actual command doesn't matter | ||
private val cmd = Commands.SignRoot | ||
|
||
test("expirationDate from fallback") { | ||
val d = CommandHandler.expirationDate(Config(cmd), oneDay, now) | ||
d shouldBe inADay | ||
} | ||
|
||
test("expirationDate from expireOn") { | ||
val d = CommandHandler.expirationDate(Config(cmd, expireOn = Some(inADay)), Period.ZERO, now) | ||
d shouldBe inADay | ||
} | ||
|
||
test("expirationDate from expireOn in the past") { | ||
intercept[PastDate] { | ||
CommandHandler.expirationDate(Config(cmd, expireOn = Some(now.minusSeconds(1))), Period.ZERO, now) | ||
} | ||
} | ||
|
||
test("expirationDate from expireOn in the past, but forced") { | ||
val d = CommandHandler.expirationDate(Config(cmd, force = true, expireOn = Some(now.minusSeconds(1))), | ||
Period.ZERO, now) | ||
d shouldBe now.minusSeconds(1) | ||
} | ||
|
||
test("expirationDate from expireAfter") { | ||
val d = CommandHandler.expirationDate(Config(cmd, expireAfter = Some(oneDay)), Period.ZERO, now) | ||
d shouldBe inADay | ||
} | ||
|
||
test("expirationDate from expireAfter in the past") { | ||
intercept[PastDate] { | ||
CommandHandler.expirationDate(Config(cmd, expireAfter = Some(Period.ofDays(-1))), Period.ZERO, now) | ||
} | ||
} | ||
|
||
test("expirationDate from expireAfter in the past, but forced") { | ||
val d = CommandHandler.expirationDate(Config(cmd, force = true, expireAfter = Some(Period.ofDays(-1))), | ||
Period.ZERO, now) | ||
d shouldBe now.minus(oneDay) | ||
} | ||
|
||
} |
Oops, something went wrong.