-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept and recognize the signature of notation client Signed-off-by: wang yan <[email protected]>
- Loading branch information
1 parent
adf80e9
commit e80253f
Showing
9 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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,46 @@ | ||
// Copyright Project Harbor 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 notation | ||
|
||
import ( | ||
"github.com/goharbor/harbor/src/pkg/accessory/model" | ||
"github.com/goharbor/harbor/src/pkg/accessory/model/base" | ||
) | ||
|
||
// Signature signature model | ||
type Signature struct { | ||
base.Default | ||
} | ||
|
||
// Kind gives the reference type of notation signature. | ||
func (c *Signature) Kind() string { | ||
return model.RefHard | ||
} | ||
|
||
// IsHard ... | ||
func (c *Signature) IsHard() bool { | ||
return true | ||
} | ||
|
||
// New returns notation signature | ||
func New(data model.AccessoryData) model.Accessory { | ||
return &Signature{base.Default{ | ||
Data: data, | ||
}} | ||
} | ||
|
||
func init() { | ||
model.Register(model.TypeNotationSignature, New) | ||
} |
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,73 @@ | ||
package notation | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/goharbor/harbor/src/pkg/accessory/model" | ||
htesting "github.com/goharbor/harbor/src/testing" | ||
) | ||
|
||
type NotationTestSuite struct { | ||
htesting.Suite | ||
accessory model.Accessory | ||
digest string | ||
subDigest string | ||
} | ||
|
||
func (suite *NotationTestSuite) SetupSuite() { | ||
suite.digest = suite.DigestString() | ||
suite.subDigest = suite.DigestString() | ||
suite.accessory, _ = model.New(model.TypeNotationSignature, | ||
model.AccessoryData{ | ||
ArtifactID: 1, | ||
SubArtifactDigest: suite.subDigest, | ||
Size: 4321, | ||
Digest: suite.digest, | ||
}) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestGetID() { | ||
suite.Equal(int64(0), suite.accessory.GetData().ID) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestGetArtID() { | ||
suite.Equal(int64(1), suite.accessory.GetData().ArtifactID) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestSubGetArtID() { | ||
suite.Equal(suite.subDigest, suite.accessory.GetData().SubArtifactDigest) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestSubGetSize() { | ||
suite.Equal(int64(4321), suite.accessory.GetData().Size) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestSubGetDigest() { | ||
suite.Equal(suite.digest, suite.accessory.GetData().Digest) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestSubGetType() { | ||
suite.Equal(model.TypeNotationSignature, suite.accessory.GetData().Type) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestSubGetRefType() { | ||
suite.Equal(model.RefHard, suite.accessory.Kind()) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestIsSoft() { | ||
suite.False(suite.accessory.IsSoft()) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestIsHard() { | ||
suite.True(suite.accessory.IsHard()) | ||
} | ||
|
||
func (suite *NotationTestSuite) TestDisplay() { | ||
suite.False(suite.accessory.Display()) | ||
} | ||
|
||
func TestCacheTestSuite(t *testing.T) { | ||
suite.Run(t, new(NotationTestSuite)) | ||
} |
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