mirror of https://github.com/docker/docs.git
Fixing unique key_id entry enforcement
Signed-off-by: Diogo Monica <diogo@docker.com>
This commit is contained in:
parent
e568babc0a
commit
c7e421a501
|
@ -23,11 +23,11 @@ type KeyDBStore struct {
|
|||
// GormPrivateKey represents a PrivateKey in the database
|
||||
type GormPrivateKey struct {
|
||||
gorm.Model
|
||||
KeyID string `gorm:"not null;unique_index"`
|
||||
Encryption string `gorm:"type:varchar(50);not null"`
|
||||
Algorithm string `gorm:"not null"`
|
||||
Public []byte `gorm:"not null"`
|
||||
Private string `gorm:"not null"`
|
||||
KeyID string `sql:"not null;unique"`
|
||||
Encryption string `sql:"not null"`
|
||||
Algorithm string `sql:"not null"`
|
||||
Public []byte `sql:"not null"`
|
||||
Private string `sql:"not null"`
|
||||
}
|
||||
|
||||
// TableName sets a specific table name for our GormPrivateKey
|
||||
|
|
|
@ -79,6 +79,10 @@ func TestDoubleCreate(t *testing.T) {
|
|||
err = dbStore.AddKey("", "", testKey)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Test writing the same key in the database. Should fail.
|
||||
err = dbStore.AddKey("", "", testKey)
|
||||
assert.Error(t, err, "failed to add private key to database:")
|
||||
|
||||
// Test writing new key succeeds
|
||||
err = dbStore.AddKey("", "", anotherTestKey)
|
||||
assert.NoError(t, err)
|
||||
|
|
Loading…
Reference in New Issue