Skip to content

Commit

Permalink
validate: fix tests for new xeipuuv/gojsonschema
Browse files Browse the repository at this point in the history
New(er) xeipuuv/gojsonschema package is trying to fetch id fields,
which in the spec were looking like this:

	"id": "https://opencontainers.org/schema/bundle/linux"

Obviously, this results in HTTP 404s, and multiple test failures.

This was fixed by opencontainers/runtime-spec#945
which ended up in runtime-spec v1.0.2.

Now, if we want to bump xeipuuv/gojsonschema (we do), we need to test
against at least v1.0.2 of runtime-spec, for the reason explained above.

Bump the spec version in all test cases, remove or fix some test cases.

In particular:

 * remove "process is required" as it needed v1.0.0-rc5 version of spec.
 * remove "args is required" as args are no longer required since commit
   opencontainers/runtime-spec@deb4d954eafc4fc.
 * fixup "invalid seccomp action" error as it now also has SCMP_ACT_LOG.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Oct 19, 2021
1 parent 28f6413 commit 08aed62
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,20 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
},
error: "",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Process: &rspec.Process{},
},
error: "1 error occurred:\n\t* args: args is required\n\n",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{},
},
error: "",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
RootfsPropagation: "",
},
Expand All @@ -82,7 +75,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
RootfsPropagation: "shared",
},
Expand All @@ -91,7 +84,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
RootfsPropagation: "rshared",
},
Expand All @@ -100,13 +93,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0-rc5",
},
error: "process: process is required",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Namespaces: []rspec.LinuxNamespace{
{
Expand All @@ -119,7 +106,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Namespaces: []rspec.LinuxNamespace{
{
Expand All @@ -132,7 +119,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Seccomp: &rspec.LinuxSeccomp{
DefaultAction: "SCMP_ACT_ALLOW",
Expand All @@ -147,7 +134,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Seccomp: &rspec.LinuxSeccomp{
DefaultAction: "SCMP_ACT_ALLOW",
Expand All @@ -162,7 +149,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Seccomp: &rspec.LinuxSeccomp{
DefaultAction: "SCMP_ACT_ALLOW",
Expand All @@ -179,7 +166,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Seccomp: &rspec.LinuxSeccomp{
DefaultAction: "SCMP_ACT_ALLOW",
Expand All @@ -192,11 +179,11 @@ func TestJSONSchema(t *testing.T) {
},
},
},
error: "linux.seccomp.syscalls.0.action: linux.seccomp.syscalls.0.action must be one of the following: \"SCMP_ACT_KILL\", \"SCMP_ACT_TRAP\", \"SCMP_ACT_ERRNO\", \"SCMP_ACT_TRACE\", \"SCMP_ACT_ALLOW\"",
error: "linux.seccomp.syscalls.0.action: linux.seccomp.syscalls.0.action must be one of the following: \"SCMP_ACT_KILL\", \"SCMP_ACT_TRAP\", \"SCMP_ACT_ERRNO\", \"SCMP_ACT_TRACE\", \"SCMP_ACT_ALLOW\", \"SCMP_ACT_LOG\"",
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Seccomp: &rspec.LinuxSeccomp{
DefaultAction: "SCMP_ACT_ALLOW",
Expand All @@ -220,7 +207,7 @@ func TestJSONSchema(t *testing.T) {
},
{
config: &rspec.Spec{
Version: "1.0.0",
Version: "1.0.2",
Linux: &rspec.Linux{
Seccomp: &rspec.LinuxSeccomp{
DefaultAction: "SCMP_ACT_ALLOW",
Expand Down Expand Up @@ -322,7 +309,7 @@ func TestCheckSemVer(t *testing.T) {
expected specerror.Code
}{
{rspec.Version, specerror.NonError},
//FIXME: validate currently only handles rpsec.Version
// FIXME: validate currently only handles rpsec.Version
{"0.0.1", specerror.NonRFCError},
{"invalid", specerror.SpecVersionInSemVer},
}
Expand Down

0 comments on commit 08aed62

Please sign in to comment.