Skip to content

Commit

Permalink
Add test to assert targets.json doesnt change after expire
Browse files Browse the repository at this point in the history
Even if assignment was completed before expire
  • Loading branch information
simao committed Jan 28, 2020
1 parent 009a945 commit 2727a77
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class DeviceResourceSpec extends DirectorSpec
deviceId
}

testWithRepo("targets.json is after after register") { implicit ns =>
testWithRepo("targets.json is empty after register") { implicit ns =>
val deviceId = registerDeviceOk()

Get(apiUri(s"device/${deviceId.show}/targets.json")).namespaced ~> routes ~> check {
Expand Down Expand Up @@ -265,6 +265,26 @@ class DeviceResourceSpec extends DirectorSpec
secondTargets.signed.version shouldBe 2
}

testWithRepo("a refreshed targets returns the same assignments as before, even if they were completed") { implicit ns =>
val regDev = registerAdminDeviceOk()

val targetUpdate = GenTargetUpdateRequest.generate
createAssignmentOk(regDev.deviceId, regDev.primary.hardwareId, targetUpdate.some)

val firstTargets = fetchRoleOk[TargetsRole](regDev.deviceId)

val deviceManifest = buildPrimaryManifest(regDev.primary, regDev.primaryKey, targetUpdate.to)

putManifestOk(regDev.deviceId, deviceManifest)

forceRoleExpire[TargetsRole](regDev.deviceId)

val secondTargets = fetchRoleOk[TargetsRole](regDev.deviceId)

secondTargets.signed.expires.isAfter(firstTargets.signed.expires)
secondTargets.signed.targets shouldBe firstTargets.signed.targets
}

testWithRepo("returns a refreshed version of snapshots if it expires") { implicit ns =>
val regDev = registerAdminDeviceOk()

Expand Down

0 comments on commit 2727a77

Please sign in to comment.