@@ -763,10 +763,8 @@ func testGC(t *testing.T, s storage.Storage) {
|
||||
result, err := s.GarbageCollect(expiry.Add(-time.Hour).In(tz))
|
||||
if err != nil {
|
||||
t.Errorf("garbage collection failed: %v", err)
|
||||
} else {
|
||||
if result.AuthCodes != 0 || result.AuthRequests != 0 {
|
||||
t.Errorf("expected no garbage collection results, got %#v", result)
|
||||
}
|
||||
} else if result.AuthCodes != 0 || result.AuthRequests != 0 {
|
||||
t.Errorf("expected no garbage collection results, got %#v", result)
|
||||
}
|
||||
if _, err := s.GetAuthCode(c.ID); err != nil {
|
||||
t.Errorf("expected to be able to get auth code after GC: %v", err)
|
||||
@@ -815,10 +813,8 @@ func testGC(t *testing.T, s storage.Storage) {
|
||||
result, err := s.GarbageCollect(expiry.Add(-time.Hour).In(tz))
|
||||
if err != nil {
|
||||
t.Errorf("garbage collection failed: %v", err)
|
||||
} else {
|
||||
if result.AuthCodes != 0 || result.AuthRequests != 0 {
|
||||
t.Errorf("expected no garbage collection results, got %#v", result)
|
||||
}
|
||||
} else if result.AuthCodes != 0 || result.AuthRequests != 0 {
|
||||
t.Errorf("expected no garbage collection results, got %#v", result)
|
||||
}
|
||||
if _, err := s.GetAuthRequest(a.ID); err != nil {
|
||||
t.Errorf("expected to be able to get auth request after GC: %v", err)
|
||||
@@ -859,10 +855,8 @@ func testGC(t *testing.T, s storage.Storage) {
|
||||
result, err := s.GarbageCollect(expiry.Add(-time.Hour).In(tz))
|
||||
if err != nil {
|
||||
t.Errorf("garbage collection failed: %v", err)
|
||||
} else {
|
||||
if result.DeviceRequests != 0 {
|
||||
t.Errorf("expected no device garbage collection results, got %#v", result)
|
||||
}
|
||||
} else if result.DeviceRequests != 0 {
|
||||
t.Errorf("expected no device garbage collection results, got %#v", result)
|
||||
}
|
||||
if _, err := s.GetDeviceRequest(d.UserCode); err != nil {
|
||||
t.Errorf("expected to be able to get auth request after GC: %v", err)
|
||||
@@ -897,10 +891,8 @@ func testGC(t *testing.T, s storage.Storage) {
|
||||
result, err := s.GarbageCollect(expiry.Add(-time.Hour).In(tz))
|
||||
if err != nil {
|
||||
t.Errorf("garbage collection failed: %v", err)
|
||||
} else {
|
||||
if result.DeviceTokens != 0 {
|
||||
t.Errorf("expected no device token garbage collection results, got %#v", result)
|
||||
}
|
||||
} else if result.DeviceTokens != 0 {
|
||||
t.Errorf("expected no device token garbage collection results, got %#v", result)
|
||||
}
|
||||
if _, err := s.GetDeviceToken(dt.DeviceCode); err != nil {
|
||||
t.Errorf("expected to be able to get device token after GC: %v", err)
|
||||
@@ -987,12 +979,12 @@ func testDeviceRequestCRUD(t *testing.T, s storage.Storage) {
|
||||
err = s.CreateDeviceRequest(d1)
|
||||
mustBeErrAlreadyExists(t, "device request", err)
|
||||
|
||||
//No manual deletes for device requests, will be handled by garbage collection routines
|
||||
//see testGC
|
||||
// No manual deletes for device requests, will be handled by garbage collection routines
|
||||
// see testGC
|
||||
}
|
||||
|
||||
func testDeviceTokenCRUD(t *testing.T, s storage.Storage) {
|
||||
//Create a Token
|
||||
// Create a Token
|
||||
d1 := storage.DeviceToken{
|
||||
DeviceCode: storage.NewID(),
|
||||
Status: "pending",
|
||||
@@ -1010,7 +1002,7 @@ func testDeviceTokenCRUD(t *testing.T, s storage.Storage) {
|
||||
err := s.CreateDeviceToken(d1)
|
||||
mustBeErrAlreadyExists(t, "device token", err)
|
||||
|
||||
//Update the device token, simulate a redemption
|
||||
// Update the device token, simulate a redemption
|
||||
if err := s.UpdateDeviceToken(d1.DeviceCode, func(old storage.DeviceToken) (storage.DeviceToken, error) {
|
||||
old.Token = "token data"
|
||||
old.Status = "complete"
|
||||
@@ -1019,13 +1011,13 @@ func testDeviceTokenCRUD(t *testing.T, s storage.Storage) {
|
||||
t.Fatalf("failed to update device token: %v", err)
|
||||
}
|
||||
|
||||
//Retrieve the device token
|
||||
// Retrieve the device token
|
||||
got, err := s.GetDeviceToken(d1.DeviceCode)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get device token: %v", err)
|
||||
}
|
||||
|
||||
//Validate expected result set
|
||||
// Validate expected result set
|
||||
if got.Status != "complete" {
|
||||
t.Fatalf("update failed, wanted token status=%v got %v", "complete", got.Status)
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ type Config struct {
|
||||
// Legacy field from pkg/api/types.go TypeMeta.
|
||||
// TODO(jlowdermilk): remove this after eliminating downstream dependencies.
|
||||
Kind string `json:"kind,omitempty"`
|
||||
// DEPRECATED: APIVersion is the preferred api version for communicating with the kubernetes cluster (v1, v2, etc).
|
||||
// Deprecated: APIVersion is the preferred api version for communicating with the kubernetes cluster (v1, v2, etc).
|
||||
// Because a cluster can run multiple API groups and potentially multiple versions of each, it no longer makes sense to specify
|
||||
// a single value for the cluster version.
|
||||
// This field isn't really needed anyway, so we are deprecating it without replacement.
|
||||
|
@@ -289,16 +289,19 @@ func (s *MySQL) open(logger log.Logger) (*conn, error) {
|
||||
cfg.Addr = s.Host
|
||||
}
|
||||
}
|
||||
if s.SSL.CAFile != "" || s.SSL.CertFile != "" || s.SSL.KeyFile != "" {
|
||||
|
||||
switch {
|
||||
case s.SSL.CAFile != "" || s.SSL.CertFile != "" || s.SSL.KeyFile != "":
|
||||
if err := s.makeTLSConfig(); err != nil {
|
||||
return nil, fmt.Errorf("failed to make TLS config: %v", err)
|
||||
}
|
||||
cfg.TLSConfig = mysqlSSLCustom
|
||||
} else if s.SSL.Mode == "" {
|
||||
case s.SSL.Mode == "":
|
||||
cfg.TLSConfig = mysqlSSLTrue
|
||||
} else {
|
||||
default:
|
||||
cfg.TLSConfig = s.SSL.Mode
|
||||
}
|
||||
|
||||
for k, v := range s.params {
|
||||
cfg.Params[k] = v
|
||||
}
|
||||
|
@@ -96,7 +96,7 @@ type staticPasswordsStorage struct {
|
||||
func WithStaticPasswords(s Storage, staticPasswords []Password, logger log.Logger) Storage {
|
||||
passwordsByEmail := make(map[string]Password, len(staticPasswords))
|
||||
for _, p := range staticPasswords {
|
||||
//Enable case insensitive email comparison.
|
||||
// Enable case insensitive email comparison.
|
||||
lowerEmail := strings.ToLower(p.Email)
|
||||
if _, ok := passwordsByEmail[lowerEmail]; ok {
|
||||
logger.Errorf("Attempting to create StaticPasswords with the same email id: %s", p.Email)
|
||||
|
@@ -25,7 +25,7 @@ var (
|
||||
// TODO(ericchiang): refactor ID creation onto the storage.
|
||||
var encoding = base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567")
|
||||
|
||||
//Valid characters for user codes
|
||||
// Valid characters for user codes
|
||||
const validUserCharacters = "BCDFGHJKLMNPQRSTVWXZ"
|
||||
|
||||
// NewDeviceCode returns a 32 char alphanumeric cryptographically secure string
|
||||
|
Reference in New Issue
Block a user