cognito:user_status filter in list users (#4120)
Co-authored-by: Łukasz Nowak <lukasz.nowak@idemia.com>
This commit is contained in:
parent
45fa825619
commit
16a4db1ce5
@ -327,6 +327,11 @@ class CognitoIdpResponse(BaseResponse):
|
|||||||
user_pool_id, limit=limit, pagination_token=token
|
user_pool_id, limit=limit, pagination_token=token
|
||||||
)
|
)
|
||||||
if filt:
|
if filt:
|
||||||
|
inherent_attributes = {
|
||||||
|
"cognito:user_status": lambda u: u.status,
|
||||||
|
"status": lambda u: u.enabled,
|
||||||
|
"username": lambda u: u.username,
|
||||||
|
}
|
||||||
name, value = filt.replace('"', "").replace(" ", "").split("=")
|
name, value = filt.replace('"', "").replace(" ", "").split("=")
|
||||||
users = [
|
users = [
|
||||||
user
|
user
|
||||||
@ -336,6 +341,10 @@ class CognitoIdpResponse(BaseResponse):
|
|||||||
for attr in user.attributes
|
for attr in user.attributes
|
||||||
if attr["Name"] == name and attr["Value"] == value
|
if attr["Name"] == name and attr["Value"] == value
|
||||||
]
|
]
|
||||||
|
or (
|
||||||
|
name in inherent_attributes
|
||||||
|
and inherent_attributes[name](user) == value
|
||||||
|
)
|
||||||
]
|
]
|
||||||
response = {"Users": [user.to_json(extended=True) for user in users]}
|
response = {"Users": [user.to_json(extended=True) for user in users]}
|
||||||
if token:
|
if token:
|
||||||
|
@ -1221,6 +1221,13 @@ def test_list_users():
|
|||||||
result["Users"].should.have.length_of(1)
|
result["Users"].should.have.length_of(1)
|
||||||
result["Users"][0]["Username"].should.equal(username_bis)
|
result["Users"][0]["Username"].should.equal(username_bis)
|
||||||
|
|
||||||
|
# checking Filter for inherent attributes
|
||||||
|
result = conn.list_users(
|
||||||
|
UserPoolId=user_pool_id, Filter='username = "{}"'.format(username_bis)
|
||||||
|
)
|
||||||
|
result["Users"].should.have.length_of(1)
|
||||||
|
result["Users"][0]["Username"].should.equal(username_bis)
|
||||||
|
|
||||||
|
|
||||||
@mock_cognitoidp
|
@mock_cognitoidp
|
||||||
def test_get_user_unconfirmed():
|
def test_get_user_unconfirmed():
|
||||||
|
Loading…
Reference in New Issue
Block a user