Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Dec 25, 2021
1 parent 68dbebd commit 04386ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions session/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ func (h *Handler) deleteIdentitySessions(w http.ResponseWriter, r *http.Request,
// swagger:parameters adminListIdentitySessions
// nolint:deadcode,unused
type adminListIdentitySessions struct {
// ActiveOnly is a boolean flag that filters out sessions based on the state. If no value is provided, all sessions are returned.
// Active is a boolean flag that filters out sessions based on the state. If no value is provided, all sessions are returned.
//
// required: false
// in: query
ActiveOnly bool `json:"active_only"`
Active bool `json:"active"`

adminDeleteIdentitySessions
x.PaginationParams
Expand Down Expand Up @@ -278,10 +278,10 @@ func (h *Handler) listIdentitySessions(w http.ResponseWriter, r *http.Request, p
return
}

activeRaw := r.URL.Query().Get("active_only")
activeRaw := r.URL.Query().Get("active")
activeBool, err := strconv.ParseBool(activeRaw)
if activeRaw != "" && err != nil {
h.r.Writer().WriteError(w, r, herodot.ErrBadRequest.WithError("could not parse parameter active_only"))
h.r.Writer().WriteError(w, r, herodot.ErrBadRequest.WithError("could not parse parameter active"))
return
}

Expand Down
6 changes: 3 additions & 3 deletions session/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func TestHandlerAdminSessionManagement(t *testing.T) {
require.Equal(t, http.StatusNotFound, res.StatusCode)
})

t.Run("case=should respect active_only on list", func(t *testing.T) {
t.Run("case=should respect active on list", func(t *testing.T) {
client := testhelpers.NewClientWithCookies(t)
i := identity.NewIdentity("")
require.NoError(t, reg.IdentityManager().Create(ctx, i))
Expand Down Expand Up @@ -462,10 +462,10 @@ func TestHandlerAdminSessionManagement(t *testing.T) {
expectedIDs: []uuid.UUID{sess[0].ID, sess[1].ID},
},
} {
t.Run(fmt.Sprintf("active_only=%#v", tc.activeOnly), func(t *testing.T) {
t.Run(fmt.Sprintf("active=%#v", tc.activeOnly), func(t *testing.T) {
reqURL := ts.URL + "/identities/" + i.ID.String() + "/sessions"
if tc.activeOnly != "" {
reqURL += "?active_only=" + tc.activeOnly
reqURL += "?active=" + tc.activeOnly
}
req, _ := http.NewRequest("GET", reqURL, nil)
res, err := client.Do(req)
Expand Down

0 comments on commit 04386ef

Please sign in to comment.