Skip to content

Commit

Permalink
Add signcertreq test (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored May 7, 2024
1 parent 1a17043 commit f3ffd50
Show file tree
Hide file tree
Showing 3 changed files with 302 additions and 25 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ linters-settings:
- "github.com/gorilla/websocket"
- "github.com/golang/mock/gomock"
- "github.com/prep/socketpair"
- "github.com/google/go-cmp/cmp"
- "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/api/errors"
- "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
7 changes: 7 additions & 0 deletions pkg/certificates/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,34 @@ import (
"github.com/ansible/receptor/pkg/utils"
)

// Oser is the function calls interfaces for mocking os.
type Oser interface {
ReadFile(name string) ([]byte, error)
WriteFile(name string, data []byte, perm fs.FileMode) error
}

// OsWrapper is the Wrapper structure for Oser.
type OsWrapper struct{}

// ReadFile for Oser defaults to os library call.
func (ow *OsWrapper) ReadFile(name string) ([]byte, error) {
return os.ReadFile(name)
}

// WriteFile for Oser defaults to os library call.
func (ow *OsWrapper) WriteFile(name string, data []byte, perm fs.FileMode) error {
return os.WriteFile(name, data, perm)
}

// Rsaer is the function calls interface for mocking rsa.
type Rsaer interface {
GenerateKey(random io.Reader, bits int) (*rsa.PrivateKey, error)
}

// RsaWrapper is the Wrapper structure for Rsaer.
type RsaWrapper struct{}

// GenerateKey for RsaWrapper defaults to rsa library call.
func (rw *RsaWrapper) GenerateKey(random io.Reader, bits int) (*rsa.PrivateKey, error) {
return rsa.GenerateKey(random, bits)
}
Expand Down
Loading

0 comments on commit f3ffd50

Please sign in to comment.