API: Optionally list expired keys (#20468)

* API: Optionally list expired keys

* Update docs
This commit is contained in:
Sofia Papagiannaki
2019-11-20 13:14:57 +02:00
committed by GitHub
parent 1b38d94537
commit d1c523838b
11 changed files with 46 additions and 21 deletions

View File

@@ -19,7 +19,7 @@ func init() {
func GetApiKeys(query *models.GetApiKeysQuery) error {
sess := x.Limit(100, 0).Where("org_id=? and ( expires IS NULL or expires >= ?)",
query.OrgId, timeNow().Unix()).Asc("name")
if query.IncludeInvalid {
if query.IncludeExpired {
sess = x.Limit(100, 0).Where("org_id=?", query.OrgId).Asc("name")
}

View File

@@ -91,7 +91,7 @@ func TestApiKeyDataAccess(t *testing.T) {
// advance mocked getTime by 1s
timeNow()
query := models.GetApiKeysQuery{OrgId: 1, IncludeInvalid: false}
query := models.GetApiKeysQuery{OrgId: 1, IncludeExpired: false}
err = GetApiKeys(&query)
assert.Nil(t, err)
@@ -101,7 +101,7 @@ func TestApiKeyDataAccess(t *testing.T) {
}
}
query = models.GetApiKeysQuery{OrgId: 1, IncludeInvalid: true}
query = models.GetApiKeysQuery{OrgId: 1, IncludeExpired: true}
err = GetApiKeys(&query)
assert.Nil(t, err)