Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squelch the 404 error on token delete #808

Merged
merged 2 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion identity/resource_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ func (a TokensAPI) Read(tokenID string) (TokenInfo, error) {

// Delete will delete the token given a token id
func (a TokensAPI) Delete(tokenID string) error {
return a.client.Post(a.context, "/token/delete", map[string]string{
err := a.client.Post(a.context, "/token/delete", map[string]string{
"token_id": tokenID,
}, nil)
if common.IsMissing(err) {
return nil
}
return err
}

// ResourceToken refreshes token in case it's expired
Expand Down
17 changes: 17 additions & 0 deletions identity/resource_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ func TestResourceTokenDelete(t *testing.T) {
assert.Equal(t, "abc", d.Id())
}

func TestResourceTokenDelete_NotFoundNoError(t *testing.T) {
_, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "POST",
Resource: "/api/2.0/token/delete",
Response: common.NotFound("RESOURCE_DOES_NOT_EXIST"), // per documentation this is the error response
Status: 404,
},
},
Resource: ResourceToken(),
Delete: true,
ID: "abc",
}.Apply(t)
assert.NoError(t, err, err)
}

func TestResourceTokenDelete_Error(t *testing.T) {
d, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
Expand Down