Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/pyopenssl-23.3.0
Browse files Browse the repository at this point in the history
Signed-off-by: Rita Zerrizuela <zeta@widcket.com>
  • Loading branch information
Widcket authored Oct 26, 2023
2 parents 5c4d481 + 1588c9f commit d83041c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion auth0/authentication/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,27 @@ def signup(
return data

def change_password(
self, email: str, connection: str, password: str | None = None
self,
email: str,
connection: str,
password: str | None = None,
organization: str | None = None,
) -> str:
"""Asks to change a password for a given user.
email (str): The user's email address.
connection (str): The name of the database connection where this user should be created.
organization (str, optional): The id of the Organization associated with the user.
"""
body = {
"client_id": self.client_id,
"email": email,
"connection": connection,
}
if organization:
body["organization"] = organization

data: str = self.post(
f"{self.protocol}://{self.domain}/dbconnections/change_password",
Expand Down
22 changes: 22 additions & 0 deletions auth0/test/authentication/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,25 @@ def test_change_password(self, mock_post):
"connection": "conn",
},
)

@mock.patch("auth0.rest.RestClient.post")
def test_change_password_with_organization_param(self, mock_post):
d = Database("my.domain.com", "cid")

# ignores the password argument
d.change_password(
email="a@b.com", password="pswd", connection="conn", organization="org_id"
)

args, kwargs = mock_post.call_args

self.assertEqual(args[0], "https://my.domain.com/dbconnections/change_password")
self.assertEqual(
kwargs["data"],
{
"client_id": "cid",
"email": "a@b.com",
"connection": "conn",
"organization": "org_id",
},
)

0 comments on commit d83041c

Please sign in to comment.