Skip to content

Commit

Permalink
test(pkg/distribution): add initial index entry signature unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Massimiliano Giovagnoli <[email protected]>
  • Loading branch information
maxgio92 committed Jul 20, 2023
1 parent cd4d0b7 commit b56c02e
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions build/registry/pkg/distribution/index_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright (C) 2022 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package distribution

import (
"reflect"
"testing"

"github.com/falcosecurity/falcoctl/pkg/index"

"github.com/falcosecurity/plugins/build/registry/pkg/registry"
)

func TestPluginToIndexEntrySignature(t *testing.T) {
signature := &index.Signature{
Cosign: &index.CosignSignature{
CertificateOidcIssuer: "",
CertificateOidcIssuerRegexp: "",
CertificateIdentity: "",
CertificateIdentityRegexp: "",
CertificateGithubWorkflow: "",
}}

expected := signature

p := registry.Plugin{
Name: "",
Description: "",
Authors: "",
Contact: "",
Maintainers: nil,
Keywords: nil,
URL: "",
RulesURL: "",
License: "",
Reserved: false,
Capabilities: registry.Capabilities{},
Signature: signature,
}
entry := pluginToIndexEntry(p, "", "")

if !reflect.DeepEqual(entry.Signature, expected) {
t.Fatalf("Index entry signature: expected %#v, got %v", expected, entry.Signature)
}
}

0 comments on commit b56c02e

Please sign in to comment.