diff --git a/sa/database.go b/sa/database.go index ebd65f52d..713a68990 100644 --- a/sa/database.go +++ b/sa/database.go @@ -11,6 +11,7 @@ import ( "net/url" "strings" + // Provide access to the MySQL driver _ "github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/go-sql-driver/mysql" gorp "github.com/letsencrypt/boulder/Godeps/_workspace/src/gopkg.in/gorp.v1" "github.com/letsencrypt/boulder/core" diff --git a/sa/storage-authority.go b/sa/storage-authority.go index 940f0bb39..b371ab5d9 100644 --- a/sa/storage-authority.go +++ b/sa/storage-authority.go @@ -212,16 +212,16 @@ func (ssa *SQLStorageAuthority) GetAuthorization(id string) (authz core.Authoriz } // GetLatestValidAuthorization gets the valid authorization with biggest expire date for a given domain and registrationId -func (ssa *SQLStorageAuthority) GetLatestValidAuthorization(registrationId int64, identifier core.AcmeIdentifier) (authz core.Authorization, err error) { +func (ssa *SQLStorageAuthority) GetLatestValidAuthorization(registrationID int64, identifier core.AcmeIdentifier) (authz core.Authorization, err error) { ident, err := json.Marshal(identifier) if err != nil { return } var auth core.Authorization err = ssa.dbMap.SelectOne(&auth, "SELECT id FROM authz "+ - "WHERE identifier = :identifier AND registrationID = :registrationId AND status = 'valid' "+ + "WHERE identifier = :identifier AND registrationID = :registrationID AND status = 'valid' "+ "ORDER BY expires DESC LIMIT 1", - map[string]interface{}{"identifier": string(ident), "registrationId": registrationId}) + map[string]interface{}{"identifier": string(ident), "registrationID": registrationID}) if err != nil { return } @@ -229,15 +229,18 @@ func (ssa *SQLStorageAuthority) GetLatestValidAuthorization(registrationId int64 return ssa.GetAuthorization(auth.ID) } +// TooManyCertificatesError indicates that the number of certificates returned by +// CountCertificates exceeded the hard-coded limit of 10,000 certificates. type TooManyCertificatesError string func (t TooManyCertificatesError) Error() string { return string(t) } -// CountCertificates returns the number of certificates issued within a time +// CountCertificatesByName returns the number of certificates issued within a time // period containing DNSNames that are equal to, or subdomains of, the given // domain name. +// // The highest count this function can return is 10,000. If there are more // certificates than that matching the provided domain name, it will return // TooManyCertificatesError. diff --git a/sa/storage-authority_test.go b/sa/storage-authority_test.go index 801a78055..955f7be9e 100644 --- a/sa/storage-authority_test.go +++ b/sa/storage-authority_test.go @@ -168,10 +168,10 @@ func TestAddAuthorization(t *testing.T) { } func CreateDomainAuth(t *testing.T, domainName string, sa *SQLStorageAuthority) (authz core.Authorization) { - return CreateDomainAuthWithRegId(t, domainName, sa, 42) + return CreateDomainAuthWithRegID(t, domainName, sa, 42) } -func CreateDomainAuthWithRegId(t *testing.T, domainName string, sa *SQLStorageAuthority, regID int64) (authz core.Authorization) { +func CreateDomainAuthWithRegID(t *testing.T, domainName string, sa *SQLStorageAuthority, regID int64) (authz core.Authorization) { // create pending auth authz, err := sa.NewPendingAuthorization(core.Authorization{RegistrationID: regID, Challenges: []core.Challenge{core.Challenge{}}}) @@ -212,7 +212,7 @@ func TestGetLatestValidAuthorizationBasic(t *testing.T) { reg := satest.CreateWorkingRegistration(t, sa) // authorize "example.org" - authz = CreateDomainAuthWithRegId(t, "example.org", sa, reg.ID) + authz = CreateDomainAuthWithRegID(t, "example.org", sa, reg.ID) // finalize auth authz.Status = core.StatusValid @@ -243,7 +243,7 @@ func TestGetLatestValidAuthorizationMultiple(t *testing.T) { reg := satest.CreateWorkingRegistration(t, sa) // create invalid authz - authz := CreateDomainAuthWithRegId(t, domain, sa, reg.ID) + authz := CreateDomainAuthWithRegID(t, domain, sa, reg.ID) exp := time.Now().AddDate(0, 0, 10) // expire in 10 day authz.Expires = &exp authz.Status = core.StatusInvalid @@ -255,7 +255,7 @@ func TestGetLatestValidAuthorizationMultiple(t *testing.T) { test.AssertError(t, err, "Should not have found a valid auth for "+domain) // create valid auth - authz = CreateDomainAuthWithRegId(t, domain, sa, reg.ID) + authz = CreateDomainAuthWithRegID(t, domain, sa, reg.ID) exp = time.Now().AddDate(0, 0, 1) // expire in 1 day authz.Expires = &exp authz.Status = core.StatusValid @@ -271,7 +271,7 @@ func TestGetLatestValidAuthorizationMultiple(t *testing.T) { test.AssertEquals(t, authz.RegistrationID, reg.ID) // create a newer auth - newAuthz := CreateDomainAuthWithRegId(t, domain, sa, reg.ID) + newAuthz := CreateDomainAuthWithRegID(t, domain, sa, reg.ID) exp = time.Now().AddDate(0, 0, 2) // expire in 2 day newAuthz.Expires = &exp newAuthz.Status = core.StatusValid