diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2019-07-08 23:15:32 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2019-07-08 23:33:40 +0100 |
commit | 8b1ee3e95010681d98d1b31af98f0ce0832cedd2 (patch) | |
tree | f28c5345cb62351ff17119c28844f804eb179bfa /server/store | |
parent | 46ec5eda8de3580592692a4bd7fb3b54e66fc0f2 (diff) |
Fix revocations query and UI
Use `Exec` rather than `Query` to update revoked status
`Query` works with MySQL but `Exec` is needed with sqlite
Test that the key is revoked
Correct column ordering
Diffstat (limited to 'server/store')
-rw-r--r-- | server/store/sqldb.go | 5 | ||||
-rw-r--r-- | server/store/store_test.go | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/server/store/sqldb.go b/server/store/sqldb.go index de242eb..8ca34a9 100644 --- a/server/store/sqldb.go +++ b/server/store/sqldb.go @@ -145,7 +145,8 @@ func (db *sqlStore) List(includeExpired bool) ([]*CertRecord, error) { // Revoke an issued cert by id. func (db *sqlStore) Revoke(ids []string) error { - if err := db.conn.Ping(); err != nil { + var err error + if err = db.conn.Ping(); err != nil { return errors.Wrap(err, "unable to connect to database") } q, args, err := sqlx.In("UPDATE issued_certs SET revoked = 1 WHERE key_id IN (?)", ids) @@ -153,7 +154,7 @@ func (db *sqlStore) Revoke(ids []string) error { return err } q = db.conn.Rebind(q) - _, err = db.conn.Query(q, args...) + _, err = db.conn.Exec(q, args...) return err } diff --git a/server/store/store_test.go b/server/store/store_test.go index 628c539..90a494e 100644 --- a/server/store/store_test.go +++ b/server/store/store_test.go @@ -93,6 +93,9 @@ func testStore(t *testing.T, db CertStorer) { if err != nil { t.Error(err) } + if len(revoked) != 1 { + t.Errorf("Expected 1 revoked key, got %d", len(revoked)) + } for _, k := range revoked { if k.KeyID != "key" { t.Errorf("Unexpected key: %s", k.KeyID) |