go lint fixes

Signed-off-by: Jessica Frazelle <acidburn@docker.com>
This commit is contained in:
Jessica Frazelle 2016-02-11 15:37:54 -08:00
parent ed3c63a8bc
commit 7955e268c7
No known key found for this signature in database
GPG Key ID: 18F3685C0022BFF3
14 changed files with 45 additions and 45 deletions

View File

@ -197,7 +197,7 @@ func setup(t *testing.T) *testCtx {
paDbMap, err := sa.NewDbMap(vars.DBConnPolicy)
test.AssertNotError(t, err, "Could not construct dbMap")
pa, err := policy.NewPolicyAuthorityImpl(paDbMap, false, nil)
pa, err := policy.New(paDbMap, false, nil)
test.AssertNotError(t, err, "Couldn't create PADB")
paDBCleanUp := test.ResetPolicyTestDatabase(t)

View File

@ -77,7 +77,7 @@ func main() {
cmd.FailOnError(err, "Couldn't load DB URL")
paDbMap, err := sa.NewDbMap(dbURL)
cmd.FailOnError(err, "Couldn't connect to policy database")
pa, err := policy.NewPolicyAuthorityImpl(paDbMap, c.PA.EnforcePolicyWhitelist, c.PA.Challenges)
pa, err := policy.New(paDbMap, c.PA.EnforcePolicyWhitelist, c.PA.Challenges)
cmd.FailOnError(err, "Couldn't create PA")
priv, err := loadPrivateKey(c.CA.Key)

View File

@ -41,7 +41,7 @@ func main() {
bundle = append(bundle, ct.ASN1Cert(cert.Raw))
}
pubi := publisher.NewPublisherImpl(bundle, logs)
pubi := publisher.New(bundle, logs)
go cmd.DebugServer(c.Publisher.DebugAddr)
go cmd.ProfileCmd("Publisher", stats)

View File

@ -35,7 +35,7 @@ func main() {
cmd.FailOnError(err, "Couldn't load DB URL")
paDbMap, err := sa.NewDbMap(dbURL)
cmd.FailOnError(err, "Couldn't connect to policy database")
pa, err := policy.NewPolicyAuthorityImpl(paDbMap, c.PA.EnforcePolicyWhitelist, c.PA.Challenges)
pa, err := policy.New(paDbMap, c.PA.EnforcePolicyWhitelist, c.PA.Challenges)
cmd.FailOnError(err, "Couldn't create PA")
rateLimitPolicies, err := cmd.LoadRateLimitPolicies(c.RA.RateLimitPoliciesFilename)

View File

@ -77,7 +77,7 @@ type certChecker struct {
}
func newChecker(saDbMap *gorp.DbMap, paDbMap *gorp.DbMap, clk clock.Clock, enforceWhitelist bool, challengeTypes map[string]bool) certChecker {
pa, err := policy.NewPolicyAuthorityImpl(paDbMap, enforceWhitelist, challengeTypes)
pa, err := policy.New(paDbMap, enforceWhitelist, challengeTypes)
cmd.FailOnError(err, "Failed to create PA")
c := certChecker{
pa: pa,

View File

@ -102,7 +102,7 @@ func main() {
app.Run(os.Args)
}
func setupFromContext(context *cli.Context) (*policy.PolicyAuthorityDatabaseImpl, string) {
func setupFromContext(context *cli.Context) (*policy.AuthorityDatabaseImpl, string) {
configFileName := context.GlobalString("config")
configJSON, err := ioutil.ReadFile(configFileName)
cmd.FailOnError(err, "Couldn't read configuration file")
@ -115,7 +115,7 @@ func setupFromContext(context *cli.Context) (*policy.PolicyAuthorityDatabaseImpl
dbMap, err := sa.NewDbMap(dbURL)
cmd.FailOnError(err, "Failed to create DB map")
padb, err := policy.NewPolicyAuthorityDatabaseImpl(dbMap)
padb, err := policy.NewAuthorityDatabaseImpl(dbMap)
cmd.FailOnError(err, "Could not connect to PADB")
ruleFile := context.GlobalString("rule-file")

View File

@ -50,22 +50,22 @@ type gorpDbMap interface {
Select(interface{}, string, ...interface{}) ([]interface{}, error)
}
// PolicyAuthorityDatabaseImpl enforces policy decisions based on various rule
// AuthorityDatabaseImpl enforces policy decisions based on various rule
// lists
type PolicyAuthorityDatabaseImpl struct {
type AuthorityDatabaseImpl struct {
log *blog.AuditLogger
dbMap gorpDbMap
}
// NewPolicyAuthorityDatabaseImpl constructs a Policy Authority Database (and
// NewAuthorityDatabaseImpl constructs a Policy Authority Database (and
// creates tables if they are non-existent)
func NewPolicyAuthorityDatabaseImpl(dbMap gorpDbMap) (padb *PolicyAuthorityDatabaseImpl, err error) {
func NewAuthorityDatabaseImpl(dbMap gorpDbMap) (padb *AuthorityDatabaseImpl, err error) {
logger := blog.GetAuditLogger()
dbMap.AddTableWithName(BlacklistRule{}, "blacklist")
dbMap.AddTableWithName(WhitelistRule{}, "whitelist")
padb = &PolicyAuthorityDatabaseImpl{
padb = &AuthorityDatabaseImpl{
dbMap: dbMap,
log: logger,
}
@ -75,7 +75,7 @@ func NewPolicyAuthorityDatabaseImpl(dbMap gorpDbMap) (padb *PolicyAuthorityDatab
// LoadRules loads the whitelist and blacklist into the database in a transaction
// deleting any previous content
func (padb *PolicyAuthorityDatabaseImpl) LoadRules(rs RuleSet) error {
func (padb *AuthorityDatabaseImpl) LoadRules(rs RuleSet) error {
tx, err := padb.dbMap.Begin()
if err != nil {
tx.Rollback()
@ -105,7 +105,7 @@ func (padb *PolicyAuthorityDatabaseImpl) LoadRules(rs RuleSet) error {
// DumpRules retrieves all domainRules in the database so they can be written to
// disk
func (padb *PolicyAuthorityDatabaseImpl) DumpRules() (rs RuleSet, err error) {
func (padb *AuthorityDatabaseImpl) DumpRules() (rs RuleSet, err error) {
var bList []BlacklistRule
_, err = padb.dbMap.Select(&bList, "SELECT * FROM blacklist")
if err != nil {
@ -127,7 +127,7 @@ func (padb *PolicyAuthorityDatabaseImpl) DumpRules() (rs RuleSet, err error) {
// allowedByBlacklist returns nil if the host is allowed, errBlacklisted if the
// host is disallowed, or an InternalServerError if there was another problem
// checking the database.
func (padb *PolicyAuthorityDatabaseImpl) allowedByBlacklist(host string) error {
func (padb *AuthorityDatabaseImpl) allowedByBlacklist(host string) error {
var rule BlacklistRule
// Use lexical ordering to quickly find blacklisted root domains
err := padb.dbMap.SelectOne(
@ -151,7 +151,7 @@ func (padb *PolicyAuthorityDatabaseImpl) allowedByBlacklist(host string) error {
return nil
}
func (padb *PolicyAuthorityDatabaseImpl) allowedByWhitelist(host string) bool {
func (padb *AuthorityDatabaseImpl) allowedByWhitelist(host string) bool {
var rule WhitelistRule
err := padb.dbMap.SelectOne(
&rule,
@ -171,7 +171,7 @@ func (padb *PolicyAuthorityDatabaseImpl) allowedByWhitelist(host string) bool {
// if both whitelist and blacklist rules are found the blacklist will always win
// Returns errNotWhitelisted, errBlacklisted, or errDBFailure for the
// appropriate problems, or nil if the host is allowable.
func (padb *PolicyAuthorityDatabaseImpl) CheckHostLists(host string, requireWhitelisted bool) error {
func (padb *AuthorityDatabaseImpl) CheckHostLists(host string, requireWhitelisted bool) error {
if requireWhitelisted {
if !padb.allowedByWhitelist(host) {
return errNotWhitelisted

View File

@ -16,11 +16,11 @@ import (
gorp "github.com/letsencrypt/boulder/Godeps/_workspace/src/gopkg.in/gorp.v1"
)
func padbImpl(t *testing.T) (*PolicyAuthorityDatabaseImpl, func()) {
func padbImpl(t *testing.T) (*AuthorityDatabaseImpl, func()) {
dbMap, err := sa.NewDbMap(vars.DBConnPolicy)
test.AssertNotError(t, err, "Could not construct dbMap")
padb, err := NewPolicyAuthorityDatabaseImpl(dbMap)
padb, err := NewAuthorityDatabaseImpl(dbMap)
test.AssertNotError(t, err, "Couldn't create PADB")
cleanUp := test.ResetPolicyTestDatabase(t)
@ -76,7 +76,7 @@ func (f *failureDB) Select(interface{}, string, ...interface{}) ([]interface{},
}
func TestBlacklistError(t *testing.T) {
p, err := NewPolicyAuthorityDatabaseImpl(&failureDB{})
p, err := NewAuthorityDatabaseImpl(&failureDB{})
test.AssertNotError(t, err, "Couldn't make PA")
err = p.CheckHostLists("bad.com", false)
test.AssertEquals(t, err, errDBFailure)

View File

@ -18,28 +18,28 @@ import (
blog "github.com/letsencrypt/boulder/log"
)
// PolicyAuthorityImpl enforces CA policy decisions.
type PolicyAuthorityImpl struct {
// AuthorityImpl enforces CA policy decisions.
type AuthorityImpl struct {
log *blog.AuditLogger
DB *PolicyAuthorityDatabaseImpl
DB *AuthorityDatabaseImpl
EnforceWhitelist bool
enabledChallenges map[string]bool
pseudoRNG *rand.Rand
}
// NewPolicyAuthorityImpl constructs a Policy Authority.
func NewPolicyAuthorityImpl(dbMap *gorp.DbMap, enforceWhitelist bool, challengeTypes map[string]bool) (*PolicyAuthorityImpl, error) {
// New constructs a Policy Authority.
func New(dbMap *gorp.DbMap, enforceWhitelist bool, challengeTypes map[string]bool) (*AuthorityImpl, error) {
logger := blog.GetAuditLogger()
logger.Notice("Policy Authority Starting")
// Setup policy db
padb, err := NewPolicyAuthorityDatabaseImpl(dbMap)
padb, err := NewAuthorityDatabaseImpl(dbMap)
if err != nil {
return nil, err
}
pa := PolicyAuthorityImpl{
pa := AuthorityImpl{
log: logger,
DB: padb,
EnforceWhitelist: enforceWhitelist,
@ -130,7 +130,7 @@ var (
// where comparison is case-independent (normalized to lower case)
//
// If WillingToIssue returns an error, it will be of type MalformedRequestError.
func (pa PolicyAuthorityImpl) WillingToIssue(id core.AcmeIdentifier, regID int64) error {
func (pa AuthorityImpl) WillingToIssue(id core.AcmeIdentifier, regID int64) error {
if id.Type != core.IdentifierDNS {
return errInvalidIdentifier
}
@ -212,7 +212,7 @@ func (pa PolicyAuthorityImpl) WillingToIssue(id core.AcmeIdentifier, regID int64
// acceptable for the given identifier.
//
// Note: Current implementation is static, but future versions may not be.
func (pa PolicyAuthorityImpl) ChallengesFor(identifier core.AcmeIdentifier, accountKey *jose.JsonWebKey) ([]core.Challenge, [][]int) {
func (pa AuthorityImpl) ChallengesFor(identifier core.AcmeIdentifier, accountKey *jose.JsonWebKey) ([]core.Challenge, [][]int) {
challenges := []core.Challenge{}
if pa.enabledChallenges[core.ChallengeTypeHTTP01] {

View File

@ -27,9 +27,9 @@ var enabledChallenges = map[string]bool{
core.ChallengeTypeDNS01: true,
}
func paImpl(t *testing.T) (*PolicyAuthorityImpl, func()) {
func paImpl(t *testing.T) (*AuthorityImpl, func()) {
dbMap, cleanUp := paDBMap(t)
pa, err := NewPolicyAuthorityImpl(dbMap, false, enabledChallenges)
pa, err := New(dbMap, false, enabledChallenges)
if err != nil {
cleanUp()
t.Fatalf("Couldn't create policy implementation: %s", err)
@ -217,7 +217,7 @@ func TestChallengesFor(t *testing.T) {
func TestWillingToIssueWithWhitelist(t *testing.T) {
dbMap, cleanUp := paDBMap(t)
defer cleanUp()
pa, err := NewPolicyAuthorityImpl(dbMap, true, nil)
pa, err := New(dbMap, true, nil)
test.AssertNotError(t, err, "Couldn't create policy implementation")
googID := core.AcmeIdentifier{
Type: core.IdentifierDNS,

View File

@ -53,8 +53,8 @@ type ctSubmissionRequest struct {
Chain []string `json:"chain"`
}
// PublisherImpl defines a Publisher
type PublisherImpl struct {
// Impl defines a Publisher
type Impl struct {
log *blog.AuditLogger
client *http.Client
issuerBundle []ct.ASN1Cert
@ -63,9 +63,9 @@ type PublisherImpl struct {
SA core.StorageAuthority
}
// NewPublisherImpl creates a Publisher that will submit certificates
// New creates a Publisher that will submit certificates
// to any CT logs configured in CTConfig
func NewPublisherImpl(bundle []ct.ASN1Cert, logs []*Log) (pub PublisherImpl) {
func New(bundle []ct.ASN1Cert, logs []*Log) (pub Impl) {
logger := blog.GetAuditLogger()
logger.Notice("Publisher Authority Starting")
@ -78,7 +78,7 @@ func NewPublisherImpl(bundle []ct.ASN1Cert, logs []*Log) (pub PublisherImpl) {
// SubmitToCT will submit the certificate represented by certDER to any CT
// logs configured in pub.CT.Logs
func (pub *PublisherImpl) SubmitToCT(der []byte) error {
func (pub *Impl) SubmitToCT(der []byte) error {
cert, err := x509.ParseCertificate(der)
if err != nil {
pub.log.Audit(fmt.Sprintf("Failed to parse certificate: %s", err))

View File

@ -253,10 +253,10 @@ func badLogSrv() *httptest.Server {
return server
}
func setup(t *testing.T) (*PublisherImpl, *x509.Certificate, *ecdsa.PrivateKey) {
func setup(t *testing.T) (*Impl, *x509.Certificate, *ecdsa.PrivateKey) {
intermediatePEM, _ := pem.Decode([]byte(testIntermediate))
pub := NewPublisherImpl(nil, nil)
pub := New(nil, nil)
pub.issuerBundle = append(pub.issuerBundle, ct.ASN1Cert(intermediatePEM.Bytes))
pub.SA = mocks.NewStorageAuthority(clock.NewFake())
@ -270,7 +270,7 @@ func setup(t *testing.T) (*PublisherImpl, *x509.Certificate, *ecdsa.PrivateKey)
return &pub, leaf, k
}
func addLog(t *testing.T, pub *PublisherImpl, port int, pubKey *ecdsa.PublicKey) {
func addLog(t *testing.T, pub *Impl, port int, pubKey *ecdsa.PublicKey) {
verifier, err := ct.NewSignatureVerifier(pubKey)
test.AssertNotError(t, err, "Couldn't create signature verifier")

View File

@ -211,7 +211,7 @@ func initAuthorities(t *testing.T) (*DummyValidationAuthority, *sa.SQLStorageAut
t.Fatalf("Failed to create dbMap: %s", err)
}
policyDBCleanUp := test.ResetPolicyTestDatabase(t)
pa, err := policy.NewPolicyAuthorityImpl(paDbMap, false, SupportedChallenges)
pa, err := policy.New(paDbMap, false, SupportedChallenges)
test.AssertNotError(t, err, "Couldn't create PA")
stats, _ := statsd.NewNoopClient()
@ -666,13 +666,13 @@ func TestNewCertificate(t *testing.T) {
sa.FinalizeAuthorization(authzFinalWWW)
// Check that we fail if the CSR signature is invalid
ExampleCSR.Signature[0] += 1
ExampleCSR.Signature[0]++
certRequest := core.CertificateRequest{
CSR: ExampleCSR,
}
_, err := ra.NewCertificate(certRequest, Registration.ID)
ExampleCSR.Signature[0] -= 1
ExampleCSR.Signature[0]--
test.AssertError(t, err, "Failed to check CSR signature")
// Check that we don't fail on case mismatches

View File

@ -118,7 +118,7 @@ func (ac *amqpConnector) cancel() {
// publish publishes a message onto the provided queue. We provide this wrapper
// because it requires locking around the read of ac.channel.
func (ac *amqpConnector) publish(queueName, corrId, expiration, replyTo, msgType string, body []byte) error {
func (ac *amqpConnector) publish(queueName, corrID, expiration, replyTo, msgType string, body []byte) error {
ac.mu.RLock()
channel := ac.channel
ac.mu.RUnlock()
@ -129,7 +129,7 @@ func (ac *amqpConnector) publish(queueName, corrId, expiration, replyTo, msgType
AmqpImmediate,
amqp.Publishing{
Body: body,
CorrelationId: corrId,
CorrelationId: corrID,
Expiration: expiration,
ReplyTo: replyTo,
Type: msgType,