diff options
author | Gibheer <gibheer@gmail.com> | 2015-03-25 20:36:21 +0100 |
---|---|---|
committer | Gibheer <gibheer@gmail.com> | 2015-03-25 20:36:21 +0100 |
commit | 301d931ad76c0754e58cf024b46bebe685faafc5 (patch) | |
tree | de5c62a0d4270bc48839e977e6763646967d10aa /certificate_test.go | |
parent | b3f621a31251c225944125c17f9f97333ba33209 (diff) |
reformat everything with gofmt
Yes, I know that this will more or less destroy the history, but it had
to be done. I also adjusted my editor to use gofmt rules by default now.
Diffstat (limited to 'certificate_test.go')
-rw-r--r-- | certificate_test.go | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/certificate_test.go b/certificate_test.go index 3cb4a64..8616641 100644 --- a/certificate_test.go +++ b/certificate_test.go @@ -1,46 +1,61 @@ package pki import ( - "crypto/elliptic" -// "crypto/x509" - "crypto/x509/pkix" - "math/big" - "reflect" - "testing" + "crypto/elliptic" + "crypto/x509/pkix" + "math/big" + "reflect" + "testing" ) var ( - TestCertificateData = CertificateData{ - Subject: pkix.Name{CommonName: "foobar"}, - DNSNames: []string{"foo.bar", "example.com"}, - } + TestCertificateData = CertificateData{ + Subject: pkix.Name{CommonName: "foobar"}, + DNSNames: []string{"foo.bar", "example.com"}, + } ) func TestCertificateCreation(t *testing.T) { - pk, err := NewPrivateKeyEcdsa(elliptic.P224()) - if err != nil { t.Errorf("cert: creating private key failed: %s", err) } - - csr, err := TestCertificateData.ToCertificateRequest(pk) - if err != nil { t.Errorf("cert: creating csr failed: %s", err) } - - cert_opts := CertificateOptions{ - // KeyUsage: x509.KeyUsageEncipherOnly | x509.KeyUsageKeyEncipherment | x509.KeyUsageCertSign, - SerialNumber: big.NewInt(1), - } - - cert, err := csr.ToCertificate(pk, cert_opts, nil) - if err != nil { t.Errorf("cert: creating cert failed: %s", err) } - - if !fieldsAreSame(TestCertificateData, cert) { - t.Errorf("cert: Fields are not the same") - } + pk, err := NewPrivateKeyEcdsa(elliptic.P224()) + if err != nil { + t.Errorf("cert: creating private key failed: %s", err) + } + + csr, err := TestCertificateData.ToCertificateRequest(pk) + if err != nil { + t.Errorf("cert: creating csr failed: %s", err) + } + + cert_opts := CertificateOptions{ + // KeyUsage: x509.KeyUsageEncipherOnly | x509.KeyUsageKeyEncipherment | x509.KeyUsageCertSign, + SerialNumber: big.NewInt(1), + } + + cert, err := csr.ToCertificate(pk, cert_opts, nil) + if err != nil { + t.Errorf("cert: creating cert failed: %s", err) + } + + if !fieldsAreSame(TestCertificateData, cert) { + t.Errorf("cert: Fields are not the same") + } } func fieldsAreSame(data CertificateData, cert *Certificate) bool { - if data.Subject.CommonName != cert.Subject.CommonName { return false } - if !reflect.DeepEqual(data.Subject.Country, cert.Subject.Country) { return false } - if !reflect.DeepEqual(data.DNSNames, cert.DNSNames) { return false } - if !reflect.DeepEqual(data.IPAddresses, cert.IPAddresses) { return false } - if !reflect.DeepEqual(data.EmailAddresses, cert.EmailAddresses) { return false } - return true + if data.Subject.CommonName != cert.Subject.CommonName { + return false + } + if !reflect.DeepEqual(data.Subject.Country, cert.Subject.Country) { + return false + } + if !reflect.DeepEqual(data.DNSNames, cert.DNSNames) { + return false + } + if !reflect.DeepEqual(data.IPAddresses, cert.IPAddresses) { + return false + } + if !reflect.DeepEqual(data.EmailAddresses, cert.EmailAddresses) { + return false + } + return true } |