Fix WorkloadIdentity.TTL handling, jobspec2 testing, and hcl1 vs 2 parsing (#19024)

* make the little dots consistent
* don't trim delimiter as that over matches
* test jobspec2 package
* copy api/WorkloadIdentity.TTL -> structs
* test ttl parsing
* fix hcl1 v 2 parsing mismatch
* make jobspec(1) tests match jobspec2 tests
This commit is contained in:
Michael Schurter
2023-11-08 09:01:16 -08:00
committed by GitHub
parent 9d075c44b2
commit c4ae91f8be
11 changed files with 34 additions and 15 deletions

View File

@@ -1121,7 +1121,14 @@ func TestIdentity(t *testing.T) {
must.NotNil(t, job.TaskGroups[0].Tasks[0].Identity)
must.True(t, job.TaskGroups[0].Tasks[0].Identity.Env)
must.True(t, job.TaskGroups[0].Tasks[0].Identity.File)
must.Len(t, 1, job.TaskGroups[0].Tasks[0].Identities)
must.Eq(t, "foo", job.TaskGroups[0].Tasks[0].Identities[0].Name)
must.Eq(t, []string{"bar"}, job.TaskGroups[0].Tasks[0].Identities[0].Audience)
altID := job.TaskGroups[0].Tasks[0].Identities[0]
must.Eq(t, "foo", altID.Name)
must.Eq(t, []string{"bar"}, altID.Audience)
must.True(t, altID.File)
must.False(t, altID.Env)
must.Eq(t, "signal", altID.ChangeMode)
must.Eq(t, "sighup", altID.ChangeSignal)
must.Eq(t, 2*time.Hour, altID.TTL)
}

View File

@@ -29,8 +29,12 @@ job "identitycompat" {
# ensure parsing handles both the default and alternate identities
# properly.
identity {
name = "foo"
aud = ["bar"]
name = "foo"
aud = ["bar"]
file = true
ttl = "2h"
change_mode = "signal"
change_signal = "sighup"
}
resources {