Debian Codegraph @

cli/utils_test.go

raw symbols SCIP
1 // Copyright The Notary Project Authors.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package cliscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/cli`/
15
16 import (
17 "reflectscip-go gomod github.com/golang/go/src go1.20 reflect/"
18 "stringsscip-go gomod github.com/golang/go/src go1.20 strings/"
19 "testingscip-go gomod github.com/golang/go/src go1.20 testing/"
20
21 "github.com/notaryproject/notation-plugin-framework-go/pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/"
22 )
23
24 func TestGetValidArgsStringscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/cli`/TestGetValidArgsString().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) {
25 mdResp := pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.GetMetadataResponsescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#{
26 Namescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Name.: "Example Plugin",
27 Descriptionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Description.: "This is an description of example plugin. 🍺",
28 URLscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#URL.: "https://example.com/notation/plugin",
29 Versionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Version.: "1.0.0",
30 Capabilitiesscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Capabilities.: []pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#{
31 pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityEnvelopeGeneratorscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityEnvelopeGenerator.,
32 pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityTrustedIdentityVerifierscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityTrustedIdentityVerifier.,
33 pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityRevocationCheckVerifierscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityRevocationCheckVerifier.},
34 }
35 s := getValidArgsStringscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/cli`/getValidArgsString().(&mdResp)
36 expected := "<generate-envelope|get-plugin-metadata|verify-signature|version>"
37 if !stringsscip-go gomod github.com/golang/go/src go1.20 strings/.EqualFoldscip-go gomod github.com/golang/go/src go1.20 strings/EqualFold().(s, expected) {
38 t.Errorfscip-go gomod github.com/golang/go/src go1.20 testing/common#Errorf().("Expected %s but found %s", expected, s)
39 }
40 }
41
42 func TestGetValidArgsscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/cli`/TestGetValidArgs().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) {
43 tests := map[string]struct {
44 caps []pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#
45 args []string
46 }{
47 "sigGeneratorOnly": {
48 caps: []pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#{pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilitySignatureGeneratorscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilitySignatureGenerator.},
49 args: []string{"describe-key", "generate-signature", "get-plugin-metadata", "version"},
50 },
51 "envGeneratorOnly": {
52 caps: []pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#{pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityEnvelopeGeneratorscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityEnvelopeGenerator.},
53 args: []string{"generate-envelope", "get-plugin-metadata", "version"},
54 },
55 "verificationOnly": {
56 caps: []pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#{pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityTrustedIdentityVerifierscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityTrustedIdentityVerifier., pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityRevocationCheckVerifierscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityRevocationCheckVerifier.},
57 args: []string{"get-plugin-metadata", "verify-signature", "version"},
58 },
59 "envGenerator+verification": {
60 caps: []pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.Capabilityscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/Capability#{pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityEnvelopeGeneratorscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityEnvelopeGenerator., pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityTrustedIdentityVerifierscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityTrustedIdentityVerifier., pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.CapabilityRevocationCheckVerifierscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CapabilityRevocationCheckVerifier.},
61 args: []string{"generate-envelope", "get-plugin-metadata", "verify-signature", "version"},
62 },
63 }
64 for name, test := range tests {
65 t.Runscip-go gomod github.com/golang/go/src go1.20 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) {
66 mdResp := pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/.GetMetadataResponsescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#{
67 Namescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Name.: "Example Plugin",
68 Descriptionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Description.: "This is an description of example plugin. 🍺",
69 URLscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#URL.: "https://example.com/notation/plugin",
70 Versionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Version.: "1.0.0",
71 Capabilitiesscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/GetMetadataResponse#Capabilities.: test.caps,
72 }
73 s := getValidArgsscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/cli`/getValidArgs().(&mdResp)
74 if !reflectscip-go gomod github.com/golang/go/src go1.20 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.20 reflect/DeepEqual().(s, test.args) {
75 t.Errorfscip-go gomod github.com/golang/go/src go1.20 testing/common#Errorf().("Expected %s but found %s", test.args, s)
76 }
77 })
78 }
79 }