| 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 signaturetest |
| 15 |
|
| 16 |
import ( |
| 17 |
"testing" |
| 18 |
|
| 19 |
"github.com/notaryproject/notation-core-go/signature" |
| 20 |
) |
| 21 |
|
| 22 |
func TestGetTestLocalSigner(t *testing.T) { |
| 23 |
type args struct { |
| 24 |
keyType signature.KeyType |
| 25 |
size int |
| 26 |
} |
| 27 |
tests := []struct { |
| 28 |
name string |
| 29 |
args args |
| 30 |
wantErr bool |
| 31 |
}{ |
| 32 |
{name: "EC256", args: args{keyType: signature.KeyTypeEC, size: 256}, wantErr: false}, |
| 33 |
{name: "EC384", args: args{keyType: signature.KeyTypeEC, size: 384}, wantErr: false}, |
| 34 |
{name: "EC521", args: args{keyType: signature.KeyTypeEC, size: 521}, wantErr: false}, |
| 35 |
{name: "ECOthers", args: args{keyType: signature.KeyTypeEC, size: 520}, wantErr: true}, |
| 36 |
{name: "RSA2048", args: args{keyType: signature.KeyTypeRSA, size: 2048}, wantErr: false}, |
| 37 |
{name: "RSA3072", args: args{keyType: signature.KeyTypeRSA, size: 3072}, wantErr: false}, |
| 38 |
{name: "RSA4096", args: args{keyType: signature.KeyTypeRSA, size: 4096}, wantErr: false}, |
| 39 |
{name: "RSAOthers", args: args{keyType: signature.KeyTypeRSA, size: 4097}, wantErr: true}, |
| 40 |
{name: "Others", args: args{keyType: -1, size: 4097}, wantErr: true}, |
| 41 |
} |
| 42 |
for _, tt := range tests { |
| 43 |
t.Run(tt.name, func(t *testing.T) { |
| 44 |
_, err := GetTestLocalSigner(tt.args.keyType, tt.args.size) |
| 45 |
if (err != nil) != tt.wantErr { |
| 46 |
t.Errorf("GetTestLocalSigner() error = %v, wantErr %v", err, tt.wantErr) |
| 47 |
return |
| 48 |
} |
| 49 |
}) |
| 50 |
} |
| 51 |
} |