Add test/vars package
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
This commit is contained in:
parent
ec0d19c3e2
commit
3ce50c106b
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/letsencrypt/boulder/core"
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -97,11 +98,6 @@ const profileName = "ee"
|
|||
const caKeyFile = "../test/test-ca.key"
|
||||
const caCertFile = "../test/test-ca.pem"
|
||||
|
||||
const (
|
||||
paDBConnStr = "mysql+tcp://policy@localhost:3306/boulder_policy_test"
|
||||
saDBConnStr = "mysql+tcp://sa@localhost:3306/boulder_sa_test"
|
||||
)
|
||||
|
||||
func mustRead(path string) []byte {
|
||||
b, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
|
|
@ -121,7 +117,7 @@ type testCtx struct {
|
|||
|
||||
func setup(t *testing.T) *testCtx {
|
||||
// Create an SA
|
||||
dbMap, err := sa.NewDbMap(saDBConnStr)
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnSA)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create dbMap: %s", err)
|
||||
}
|
||||
|
|
@ -133,7 +129,7 @@ func setup(t *testing.T) *testCtx {
|
|||
}
|
||||
saDBCleanUp := test.ResetSATestDatabase(t)
|
||||
|
||||
paDbMap, err := sa.NewDbMap(paDBConnStr)
|
||||
paDbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
test.AssertNotError(t, err, "Could not construct dbMap")
|
||||
pa, err := policy.NewPolicyAuthorityImpl(paDbMap, false)
|
||||
test.AssertNotError(t, err, "Couldn't create PADB")
|
||||
|
|
|
|||
|
|
@ -26,20 +26,16 @@ import (
|
|||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/sa/satest"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
)
|
||||
|
||||
var (
|
||||
saDbConnStr = "mysql+tcp://sa@localhost:3306/boulder_sa_test"
|
||||
paDbConnStr = "mysql+tcp://policy@localhost:3306/boulder_policy_test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
func BenchmarkCheckCert(b *testing.B) {
|
||||
saDbMap, err := sa.NewDbMap(saDbConnStr)
|
||||
saDbMap, err := sa.NewDbMap(vars.DBConnSA)
|
||||
if err != nil {
|
||||
fmt.Println("Couldn't connect to database")
|
||||
return
|
||||
}
|
||||
paDbMap, err := sa.NewDbMap(paDbConnStr)
|
||||
paDbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
if err != nil {
|
||||
fmt.Println("Couldn't connect to database")
|
||||
return
|
||||
|
|
@ -78,10 +74,10 @@ func BenchmarkCheckCert(b *testing.B) {
|
|||
}
|
||||
|
||||
func TestCheckCert(t *testing.T) {
|
||||
saDbMap, err := sa.NewDbMap(saDbConnStr)
|
||||
saDbMap, err := sa.NewDbMap(vars.DBConnSA)
|
||||
test.AssertNotError(t, err, "Couldn't connect to database")
|
||||
saCleanup := test.ResetSATestDatabase(t)
|
||||
paDbMap, err := sa.NewDbMap(paDbConnStr)
|
||||
paDbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
test.AssertNotError(t, err, "Couldn't connect to policy database")
|
||||
paCleanup := test.ResetPolicyTestDatabase(t)
|
||||
defer func() {
|
||||
|
|
@ -179,9 +175,9 @@ func TestCheckCert(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetAndProcessCerts(t *testing.T) {
|
||||
saDbMap, err := sa.NewDbMap(saDbConnStr)
|
||||
saDbMap, err := sa.NewDbMap(vars.DBConnSA)
|
||||
test.AssertNotError(t, err, "Couldn't connect to database")
|
||||
paDbMap, err := sa.NewDbMap(paDbConnStr)
|
||||
paDbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
test.AssertNotError(t, err, "Couldn't connect to policy database")
|
||||
fc := clock.NewFake()
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/letsencrypt/boulder/mocks"
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
func bigIntFromB64(b64 string) *big.Int {
|
||||
|
|
@ -50,7 +51,7 @@ func (m *mockMail) Clear() {
|
|||
}
|
||||
|
||||
func (m *mockMail) SendMail(to []string, msg string) (err error) {
|
||||
for _ = range to {
|
||||
for range to {
|
||||
m.Messages = append(m.Messages, msg)
|
||||
}
|
||||
return
|
||||
|
|
@ -146,8 +147,6 @@ var testKey = rsa.PrivateKey{
|
|||
Primes: []*big.Int{p, q},
|
||||
}
|
||||
|
||||
const dbConnStr = "mysql+tcp://mailer@localhost:3306/boulder_sa_test"
|
||||
|
||||
func TestFindExpiringCertificates(t *testing.T) {
|
||||
ctx := setup(t, []time.Duration{time.Hour * 24, time.Hour * 24 * 4, time.Hour * 24 * 7})
|
||||
|
||||
|
|
@ -462,7 +461,7 @@ type testCtx struct {
|
|||
func setup(t *testing.T, nagTimes []time.Duration) *testCtx {
|
||||
// We use the test_setup user (which has full permissions to everything)
|
||||
// because the SA we return is used for inserting data to set up the test.
|
||||
dbMap, err := sa.NewDbMap("mysql+tcp://test_setup@localhost:3306/boulder_sa_test")
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnSAFullPerms)
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't connect the database: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/letsencrypt/boulder/mocks"
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
func TestCacheControl(t *testing.T) {
|
||||
|
|
@ -65,7 +66,7 @@ func TestHandler(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDBHandler(t *testing.T) {
|
||||
dbMap, err := sa.NewDbMap("mysql+tcp://ocsp_resp@localhost:3306/boulder_sa_test")
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnSAOcspResp)
|
||||
test.AssertNotError(t, err, "Could not connect to database")
|
||||
src, err := makeDBSource(dbMap, "./testdata/test-ca.der.pem", blog.GetAuditLogger())
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import (
|
|||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/sa/satest"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
type mockCA struct{}
|
||||
|
|
@ -47,12 +48,10 @@ func (p *mockPub) SubmitToCT(_ []byte) error {
|
|||
})
|
||||
}
|
||||
|
||||
const dbConnStr = "mysql+tcp://sa@localhost:3306/boulder_sa_test"
|
||||
|
||||
var log = mocks.UseMockLog()
|
||||
|
||||
func setup(t *testing.T) (OCSPUpdater, core.StorageAuthority, *gorp.DbMap, clock.FakeClock, func()) {
|
||||
dbMap, err := sa.NewDbMap(dbConnStr)
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnSA)
|
||||
test.AssertNotError(t, err, "Failed to create dbMap")
|
||||
|
||||
fc := clock.NewFake()
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ import (
|
|||
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
func padbImpl(t *testing.T) (*PolicyAuthorityDatabaseImpl, func()) {
|
||||
dbMap, err := sa.NewDbMap(dbConnStr)
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
test.AssertNotError(t, err, "Could not construct dbMap")
|
||||
|
||||
padb, err := NewPolicyAuthorityDatabaseImpl(dbMap)
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import (
|
|||
"github.com/letsencrypt/boulder/mocks"
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
var log = mocks.UseMockLog()
|
||||
var dbConnStr = "mysql+tcp://policy@localhost:3306/boulder_policy_test"
|
||||
|
||||
func paImpl(t *testing.T) (*PolicyAuthorityImpl, func()) {
|
||||
dbMap, cleanUp := paDBMap(t)
|
||||
|
|
@ -32,7 +32,7 @@ func paImpl(t *testing.T) (*PolicyAuthorityImpl, func()) {
|
|||
}
|
||||
|
||||
func paDBMap(t *testing.T) (*gorp.DbMap, func()) {
|
||||
dbMap, err := sa.NewDbMap(dbConnStr)
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
test.AssertNotError(t, err, "Could not construct dbMap")
|
||||
cleanUp := test.ResetPolicyTestDatabase(t)
|
||||
return dbMap, cleanUp
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/letsencrypt/boulder/policy"
|
||||
"github.com/letsencrypt/boulder/sa"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
type DummyValidationAuthority struct {
|
||||
|
|
@ -121,11 +122,6 @@ var (
|
|||
log = mocks.UseMockLog()
|
||||
)
|
||||
|
||||
const (
|
||||
paDBConnStr = "mysql+tcp://policy@localhost:3306/boulder_policy_test"
|
||||
saDBConnStr = "mysql+tcp://sa@localhost:3306/boulder_sa_test"
|
||||
)
|
||||
|
||||
func makeResponse(ch core.Challenge) (out core.Challenge, err error) {
|
||||
keyAuthorization, err := core.NewKeyAuthorization(ch.Token, ch.AccountKey)
|
||||
if err != nil {
|
||||
|
|
@ -156,7 +152,7 @@ func initAuthorities(t *testing.T) (*DummyValidationAuthority, *sa.SQLStorageAut
|
|||
|
||||
fc := clock.NewFake()
|
||||
|
||||
dbMap, err := sa.NewDbMap(saDBConnStr)
|
||||
dbMap, err := sa.NewDbMap(vars.DBConnSA)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create dbMap: %s", err)
|
||||
}
|
||||
|
|
@ -188,7 +184,7 @@ func initAuthorities(t *testing.T) (*DummyValidationAuthority, *sa.SQLStorageAut
|
|||
}
|
||||
signer, _ := local.NewSigner(caKey, caCert, x509.SHA256WithRSA, basicPolicy)
|
||||
ocspSigner, _ := ocsp.NewSigner(caCert, caCert, caKey, time.Hour)
|
||||
paDbMap, err := sa.NewDbMap(paDBConnStr)
|
||||
paDbMap, err := sa.NewDbMap(vars.DBConnPolicy)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create dbMap: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,16 +28,15 @@ import (
|
|||
"github.com/letsencrypt/boulder/mocks"
|
||||
"github.com/letsencrypt/boulder/sa/satest"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
"github.com/letsencrypt/boulder/test/vars"
|
||||
)
|
||||
|
||||
const dbConnStr = "mysql+tcp://sa@localhost:3306/boulder_sa_test"
|
||||
|
||||
var log = mocks.UseMockLog()
|
||||
|
||||
// initSA constructs a SQLStorageAuthority and a clean up function
|
||||
// that should be defer'ed to the end of the test.
|
||||
func initSA(t *testing.T) (*SQLStorageAuthority, clock.FakeClock, func()) {
|
||||
dbMap, err := NewDbMap(dbConnStr)
|
||||
dbMap, err := NewDbMap(vars.DBConnSA)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create dbMap: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package vars
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
dbURL = "mysql+tcp://%s@localhost:3306/%s"
|
||||
)
|
||||
|
||||
var (
|
||||
// DBConnPolicy is the policy database connection
|
||||
DBConnPolicy = fmt.Sprintf(dbURL, "policy", "boulder_policy_test")
|
||||
// DBConnPolicyIntegration is the policy integration database connection
|
||||
DBConnPolicyIntegration = fmt.Sprintf(dbURL, "policy", "boulder_policy_integration")
|
||||
// DBConnSA is the sa database connection
|
||||
DBConnSA = fmt.Sprintf(dbURL, "sa", "boulder_sa_test")
|
||||
// DBConnSAIntegration is the sa integration database connection
|
||||
DBConnSAIntegration = fmt.Sprintf(dbURL, "sa", "boulder_sa_integration")
|
||||
// DBConnSAMailer is the sa mailer database connection
|
||||
DBConnSAMailer = fmt.Sprintf(dbURL, "mailer", "boulder_sa_test")
|
||||
// DBConnSAFullPerms is the sa database connection with full perms
|
||||
DBConnSAFullPerms = fmt.Sprintf(dbURL, "test_setup", "boulder_sa_test")
|
||||
// DBConnSAOcspResp is the sa ocsp_resp database connection
|
||||
DBConnSAOcspResp = fmt.Sprintf(dbURL, "ocsp_resp", "boulder_sa_test")
|
||||
)
|
||||
Loading…
Reference in New Issue