Debian Codegraph @

plugin/describekey_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 pluginscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/
15
16 import (
17 "fmtscip-go gomod github.com/golang/go/src go1.20 fmt/"
18 "testingscip-go gomod github.com/golang/go/src go1.20 testing/"
19 )
20
21 func TestDescribeKeyRequest_Validatescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/TestDescribeKeyRequest_Validate().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) {
22 reqs := []DescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#{
23 getDescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/getDescribeKeyRequest().(ContractVersionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/ContractVersion., "someKeyId"),
24 {
25 ContractVersionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#ContractVersion.: ContractVersionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/ContractVersion.,
26 KeyIDscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#KeyID.: "someKeyId",
27 PluginConfigscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#PluginConfig.: map[string]string{"someKey": "someValue"}},
28 }
29
30 for _, req := range reqs {
31 if err := req.Validatescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#Validate().(); err != nil {
32 t.Errorfscip-go gomod github.com/golang/go/src go1.20 testing/common#Errorf().("VerifySignatureRequest#Validate failed with error: %+v", err)
33 }
34 }
35 }
36
37 func TestDescribeKeyRequest_Validate_Errorscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/TestDescribeKeyRequest_Validate_Error().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) {
38 testCases := []struct {
39 name string
40 req DescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#
41 }{
42 {name: "contractVersion", req: getDescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/getDescribeKeyRequest().("", "someKeyId")},
43 {name: "keyId", req: getDescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/getDescribeKeyRequest().(ContractVersionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/ContractVersion., "")},
44 }
45
46 for _, testcase := range testCases {
47 t.Runscip-go gomod github.com/golang/go/src go1.20 testing/T#Run().(testcase.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#) {
48 if err := testcase.req.Validatescip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#Validate().(); err != nil {
49 expMsg := fmtscip-go gomod github.com/golang/go/src go1.20 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.20 fmt/Sprintf().("{\"errorCode\":\"VALIDATION_ERROR\",\"errorMessage\":\"%s cannot be empty\"}", testcase.name)
50 if err.Error() != expMsg {
51 t.Errorfscip-go gomod github.com/golang/go/src go1.20 testing/common#Errorf().("expected error message '%s' but got '%s'", expMsg, err.Error())
52 }
53 } else {
54 t.Errorscip-go gomod github.com/golang/go/src go1.20 testing/common#Error().("DescribeKeyRequest#Validate didn't returned error")
55 }
56 })
57 }
58 }
59
60 func TestDescribeKeyRequest_Commandscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/TestDescribeKeyRequest_Command().(t *testingscip-go gomod github.com/golang/go/src go1.20 testing/.Tscip-go gomod github.com/golang/go/src go1.20 testing/T#) {
61 req := getDescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/getDescribeKeyRequest().(ContractVersionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/ContractVersion., "someKeyId")
62 if cmd := req.Commandscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#Command().(); cmd != CommandDescribeKeyscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CommandDescribeKey. {
63 t.Errorfscip-go gomod github.com/golang/go/src go1.20 testing/common#Errorf().("DescribeKeyRequest#Command, expected %s but returned %s", CommandDescribeKeyscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/CommandDescribeKey., cmd)
64 }
65 }
66
67 func getDescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/getDescribeKeyRequest().(cv, kid string) DescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest# {
68 return DescribeKeyRequestscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#{
69 ContractVersionscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#ContractVersion.: cv,
70 KeyIDscip-go gomod github.com/notaryproject/notation-plugin-framework-go . `github.com/notaryproject/notation-plugin-framework-go/plugin`/DescribeKeyRequest#KeyID.: kid,
71 }
72 }