-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from rekby/devel
Add ecdsa certificates support
- Loading branch information
Showing
10 changed files
with
400 additions
and
365 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cert_manager | ||
|
||
import ( | ||
"testing" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/maxatome/go-testdeep" | ||
) | ||
|
||
func TestCertDescription_CertStoreName(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
td.Cmp(CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA}.CertStoreName(), "asd.ru.rsa.cer") | ||
} | ||
|
||
func TestCertDescription_DomainNames(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
td.Cmp(CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA}.DomainNames(), []DomainName{"asd.ru", "www.asd.ru"}) | ||
} | ||
|
||
func TestCertDescription_KeyStoreName(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
td.Cmp(CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA}.KeyStoreName(), "asd.ru.rsa.key") | ||
} | ||
|
||
func TestCertDescription_LockName(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
td.Cmp(CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA}.LockName(), "asd.ru.lock") | ||
} | ||
|
||
func TestCertDescription_MetaStoreName(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
td.Cmp(CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA}.MetaStoreName(), "asd.ru.rsa.json") | ||
} | ||
|
||
func TestCertDescription_String(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
td.Cmp(CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA}.String(), "asd.ru.rsa") | ||
} | ||
|
||
func TestCertDescription_ZapField(t *testing.T) { | ||
td := testdeep.NewT(t) | ||
cd := CertDescription{MainDomain: "asd.ru", KeyType: KeyRSA} | ||
td.Cmp(cd.ZapField(), zap.Stringer("cert_name", cd)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//nolint:golint | ||
package cert_manager | ||
|
||
import ( | ||
"strings" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
type CertDescription struct { | ||
MainDomain string | ||
KeyType KeyType | ||
} | ||
|
||
func (n CertDescription) CertStoreName() string { | ||
return n.MainDomain + "." + n.KeyType.String() + ".cer" | ||
} | ||
|
||
func (n CertDescription) DomainNames() []DomainName { | ||
return []DomainName{DomainName(n.MainDomain), DomainName("www." + n.MainDomain)} | ||
} | ||
|
||
func (n CertDescription) KeyStoreName() string { | ||
return n.MainDomain + "." + n.KeyType.String() + ".key" | ||
} | ||
|
||
func (n CertDescription) LockName() string { | ||
return n.MainDomain + ".lock" | ||
} | ||
|
||
func (n CertDescription) MetaStoreName() string { | ||
return n.MainDomain + "." + n.KeyType.String() + ".json" | ||
} | ||
|
||
func (n CertDescription) String() string { | ||
return n.MainDomain + "." + n.KeyType.String() | ||
} | ||
|
||
func (n CertDescription) ZapField() zap.Field { | ||
return zap.Stringer("cert_name", n) | ||
} | ||
|
||
func CertDescriptionFromDomain(domain DomainName, keyType KeyType) CertDescription { | ||
return CertDescription{ | ||
MainDomain: strings.TrimPrefix(domain.String(), "www."), | ||
KeyType: keyType, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.