-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide unit tests covering signed images verification (#220)
* [#91] Provide unit tests covering signed images verification --------- Signed-off-by: Dimitar Dimitrov <[email protected]>
- Loading branch information
1 parent
8bd41e0
commit 7399402
Showing
6 changed files
with
344 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
|
||
package ctr | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/eclipse-kanto/container-management/containerm/containers/types" | ||
"github.com/eclipse-kanto/container-management/containerm/pkg/testutil" | ||
"github.com/notaryproject/notation-go/dir" | ||
) | ||
|
||
func TestContainerVerifier(t *testing.T) { | ||
t.Run("unknown_verifier", func(t *testing.T) { | ||
v, err := newContainerVerifier("unknown", nil, nil) | ||
testutil.AssertNotNil(t, err) | ||
testutil.AssertNil(t, v) | ||
}) | ||
t.Run("skip_verifier", func(t *testing.T) { | ||
v, err := newContainerVerifier(VerifierNone, nil, nil) | ||
testutil.AssertNil(t, err) | ||
testutil.AssertNotNil(t, v) | ||
testutil.AssertNil(t, v.Verify(context.Background(), types.Image{})) | ||
}) | ||
t.Run("notation_verifier", func(t *testing.T) { | ||
config := map[string]string{ | ||
notationKeyConfigDir: "testConfigDir", | ||
notationKeyLibexecDir: "testLibexecDir", | ||
} | ||
registryConfig := map[string]*RegistryConfig{ | ||
testHost: testRegConfig, | ||
} | ||
|
||
v, err := newContainerVerifier(VerifierNotation, config, registryConfig) | ||
testutil.AssertNil(t, err) | ||
testutil.AssertNotNil(t, v) | ||
testutil.AssertNotNil(t, v.Verify(context.Background(), types.Image{})) // expected fail due to invalid config dir | ||
|
||
nv := v.(*notationVerifier) | ||
testutil.AssertEqual(t, registryConfig, nv.registryConfig) | ||
testutil.AssertEqual(t, config[notationKeyConfigDir], dir.UserConfigDir) | ||
testutil.AssertEqual(t, config[notationKeyLibexecDir], dir.UserLibexecDir) | ||
|
||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.