Skip to content

Commit

Permalink
Added InitCA test (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored May 8, 2024
1 parent f3ffd50 commit da17a42
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions pkg/certificates/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//go:build !no_cert_auth
// +build !no_cert_auth

package certificates_test

import (
"testing"

"github.com/ansible/receptor/pkg/certificates"
)

func TestInitCA(t *testing.T) {
type args struct {
opts *certificates.CertOptions
certOut string
keyOut string
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "Positive test",
args: args{
opts: &certificates.CertOptions{
CommonName: "Ansible Automation Controller Nodes Mesh",
Bits: 8192,
},
certOut: "receptor_cert.pem",
keyOut: "receptor_key.pem",
},
wantErr: false,
},
{
name: "Negative test",
args: args{
opts: &certificates.CertOptions{
Bits: -1,
CommonName: "Ansible Automation Controller Nodes Mesh",
},
certOut: "receptor_cert.pem",
keyOut: "receptor_key.pem",
},
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := certificates.InitCA(tt.args.opts, tt.args.certOut, tt.args.keyOut); (err != nil) != tt.wantErr {
t.Errorf("InitCA() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

0 comments on commit da17a42

Please sign in to comment.