From 933e1bc4239196d7c216e38b40526d607cb857cf Mon Sep 17 00:00:00 2001 From: jmontesi <100689165+jmontesi@users.noreply.github.com> Date: Mon, 13 Nov 2023 12:06:45 +0100 Subject: [PATCH] claim file: move data structs and handlers to the CNF repo (#1607) --- cmd/tnf/claim/add/add_test.go | 2 +- .../testdata/claim_access_control.json | 1 - .../compare/testdata/claim_observability.json | 1 - .../claim/show/failures/testdata/claim1.json | 1 - .../claim/show/failures/testdata/claim2.json | 1 - .../results/html/results.html | 231 +++++++++++++++++- internal/version/version_test.go | 17 ++ pkg/claim/schema.go | 5 - .../claim-invalid-additional-property.json | 3 +- .../testdata/claim-invalid-bool-results.json | 3 +- .../testdata/claim-invalid-junit-payload.json | 3 +- .../claim-invalid-non-result-result.json | 3 +- pkg/claim/testdata/claim-valid.json | 3 +- 13 files changed, 253 insertions(+), 21 deletions(-) create mode 100644 internal/version/version_test.go diff --git a/cmd/tnf/claim/add/add_test.go b/cmd/tnf/claim/add/add_test.go index d7479bbdf..22cd7568b 100644 --- a/cmd/tnf/claim/add/add_test.go +++ b/cmd/tnf/claim/add/add_test.go @@ -13,7 +13,7 @@ func TestReadClaim(t *testing.T) { expectedClaimRoot *claim.Root }{ { // Test Case #1 - Happy path - testContents: `{"claim":{"versions":{"k8s":"1.23.1","tnf":"0.3.1", "claimFormat":"v0.0.1"},"configurations":{},"metadata":{"endTime":"1:33:00","startTime":"2:33:00"},"nodes":{},"results":{},"rawResults":{}}}`, + testContents: `{"claim":{"versions":{"k8s":"1.23.1","tnf":"0.3.1"},"configurations":{},"metadata":{"endTime":"1:33:00","startTime":"2:33:00"},"nodes":{},"results":{},"rawResults":{}}}`, expectedClaimRoot: &claim.Root{ Claim: &claim.Claim{ Versions: &claim.Versions{ diff --git a/cmd/tnf/claim/compare/testdata/claim_access_control.json b/cmd/tnf/claim/compare/testdata/claim_access_control.json index 064f21492..7379bb3d7 100644 --- a/cmd/tnf/claim/compare/testdata/claim_access_control.json +++ b/cmd/tnf/claim/compare/testdata/claim_access_control.json @@ -11851,7 +11851,6 @@ ] }, "versions": { - "claimFormat": "v0.1.0", "k8s": "v1.26.3+b404935", "ocClient": "n/a, (not using oc or kubectl client)", "ocp": "4.13.0", diff --git a/cmd/tnf/claim/compare/testdata/claim_observability.json b/cmd/tnf/claim/compare/testdata/claim_observability.json index 269849544..8dc53337d 100644 --- a/cmd/tnf/claim/compare/testdata/claim_observability.json +++ b/cmd/tnf/claim/compare/testdata/claim_observability.json @@ -11877,7 +11877,6 @@ ] }, "versions": { - "claimFormat": "v0.1.0", "k8s": "v1.26.4+c343423", "ocClient": "n/a, (not using oc or kubectl client)", "ocp": "4.13.1", diff --git a/cmd/tnf/claim/show/failures/testdata/claim1.json b/cmd/tnf/claim/show/failures/testdata/claim1.json index 287434596..d6a791b3d 100644 --- a/cmd/tnf/claim/show/failures/testdata/claim1.json +++ b/cmd/tnf/claim/show/failures/testdata/claim1.json @@ -119,7 +119,6 @@ ] }, "versions": { - "claimFormat": "v0.0.1", "k8s": "v1.27.3", "ocClient": "n/a, (not using oc or kubectl client)", "ocp": "n/a, (non-OpenShift cluster)", diff --git a/cmd/tnf/claim/show/failures/testdata/claim2.json b/cmd/tnf/claim/show/failures/testdata/claim2.json index a19e16e0b..a79753197 100644 --- a/cmd/tnf/claim/show/failures/testdata/claim2.json +++ b/cmd/tnf/claim/show/failures/testdata/claim2.json @@ -119,7 +119,6 @@ ] }, "versions": { - "claimFormat": "v0.0.1", "k8s": "v1.27.3", "ocClient": "n/a, (not using oc or kubectl client)", "ocp": "n/a, (non-OpenShift cluster)", diff --git a/cnf-certification-test/results/html/results.html b/cnf-certification-test/results/html/results.html index 0b9f6388e..ed34a86fc 100644 --- a/cnf-certification-test/results/html/results.html +++ b/cnf-certification-test/results/html/results.html @@ -1 +1,230 @@ -This is a placeholder for the results.html file that will be downloaded from https://github.com/test-network-function/parser when this project is built \ No newline at end of file + + + + + CNF Certification Test Parser + + + + + + + + + + + + + + + + + + + + + + + + +
+ Red Hat +

CNF Certification Test Parser

+
+

Upload file

+
+ +
+ +

Scenario

+
+ + + +
+ + +
+
+ + +
+
+ +

Results

+
+

+ Upload Feedback File: +

+ Download + Results + Download Feedback as a JSON file +
+
+
+
+
+ +
+ + Configuration + + +
+
+
+ Metadata + + + +
+
+
+ Nodes + + +
+
+
+ Results + + + + + + + + + + + + + + + + + + + + + + + Versions + + + +
+
+
+
+ + + + +
+ + + + + © 2022 Red Hat, Inc. + + + + + + + + + + + diff --git a/internal/version/version_test.go b/internal/version/version_test.go new file mode 100644 index 000000000..549e72476 --- /dev/null +++ b/internal/version/version_test.go @@ -0,0 +1,17 @@ +// Copyright (C) 2020-2023 Red Hat, Inc. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +package version diff --git a/pkg/claim/schema.go b/pkg/claim/schema.go index 588f72da8..9781769d6 100644 --- a/pkg/claim/schema.go +++ b/pkg/claim/schema.go @@ -1077,7 +1077,6 @@ func (strct *Versions) MarshalJSON() ([]byte, error) { } func (strct *Versions) UnmarshalJSON(b []byte) error { - claimFormatReceived := false tnfReceived := false var jsonMap map[string]json.RawMessage if err := json.Unmarshal(b, &jsonMap); err != nil { @@ -1111,10 +1110,6 @@ func (strct *Versions) UnmarshalJSON(b []byte) error { return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } - // check if claimFormat (a required property) was received - if !claimFormatReceived { - return errors.New("\"claimFormat\" is required but was not present") - } // check if tnf (a required property) was received if !tnfReceived { return errors.New("\"tnf\" is required but was not present") diff --git a/pkg/claim/testdata/claim-invalid-additional-property.json b/pkg/claim/testdata/claim-invalid-additional-property.json index 0f52ee9c7..898f3c5f4 100644 --- a/pkg/claim/testdata/claim-invalid-additional-property.json +++ b/pkg/claim/testdata/claim-invalid-additional-property.json @@ -6,8 +6,7 @@ "endTime": "1970-01-01T10:05:08+01:00" }, "versions": { - "tnf": "v0.0.1", - "claimFormat":"v0.0.1" + "tnf": "v0.0.1" }, "configurations": {}, "rawResults": { diff --git a/pkg/claim/testdata/claim-invalid-bool-results.json b/pkg/claim/testdata/claim-invalid-bool-results.json index ac26f4d6a..94bb6f828 100644 --- a/pkg/claim/testdata/claim-invalid-bool-results.json +++ b/pkg/claim/testdata/claim-invalid-bool-results.json @@ -212,8 +212,7 @@ } }, "versions": { - "tnf": "v0.0.3", - "claimFormat":"v0.0.1" + "tnf": "v0.0.3" }, "results": false } diff --git a/pkg/claim/testdata/claim-invalid-junit-payload.json b/pkg/claim/testdata/claim-invalid-junit-payload.json index 60a201aa3..66a899980 100644 --- a/pkg/claim/testdata/claim-invalid-junit-payload.json +++ b/pkg/claim/testdata/claim-invalid-junit-payload.json @@ -5,8 +5,7 @@ "endTime": "1970-01-01T10:05:08+01:00" }, "versions": { - "tnf": "v0.0.1", - "claimFormat":"v0.0.1" + "tnf": "v0.0.1" }, "configurations": {}, "rawResults": false, diff --git a/pkg/claim/testdata/claim-invalid-non-result-result.json b/pkg/claim/testdata/claim-invalid-non-result-result.json index 6008bcf71..d0702838b 100644 --- a/pkg/claim/testdata/claim-invalid-non-result-result.json +++ b/pkg/claim/testdata/claim-invalid-non-result-result.json @@ -212,8 +212,7 @@ } }, "versions": { - "tnf": "v0.0.3", - "claimFormat":"v0.0.1" + "tnf": "v0.0.3" }, "results": { "{\"url\":\"https://test-network-function.com/tnf/test\",{\"version\":\"v1.0.0\"}": [ diff --git a/pkg/claim/testdata/claim-valid.json b/pkg/claim/testdata/claim-valid.json index c3144642c..31395e803 100644 --- a/pkg/claim/testdata/claim-valid.json +++ b/pkg/claim/testdata/claim-valid.json @@ -212,8 +212,7 @@ } }, "versions": { - "tnf": "v0.0.3", - "claimFormat":"v0.0.1" + "tnf": "v0.0.3" }, "results": { "{\"url\":\"https://test-network-function.com/tnf/test\",{\"version\":\"v1.0.0\"}": [