nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: auth0/auth0-python
Pull request #112 (2018-06-28 19:42:48)

Adds user export job creation.
Adds the `users-exports` endpoint to the SDK for user database export job creation.


Patch:
diff --git a/auth0/v3/management/jobs.py b/auth0/v3/management/jobs.py
index c340c2a..c1831ef 100644
--- a/auth0/v3/management/jobs.py
+++ b/auth0/v3/management/jobs.py
@@ -41,6 +41,17 @@ class Jobs(object):
         url = self._url('%s/errors' % (id))
         return self.client.get(url)
 
+    def export_users(self, body):
+        """Export all users to a file using a long running job.
+
+        Check job status with get(). URL pointing to the export file will be
+        included in the status once the job is complete.
+
+        Args:
+            body (dict): Please see: https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports
+        """
+        return self.client.post(self._url('users-exports'), data=body)
+
     def import_users(self, connection_id, file_obj, upsert=False):
         """Imports users to a connection from a file.
 


Test patch:
diff --git a/auth0/v3/test/management/test_jobs.py b/auth0/v3/test/management/test_jobs.py
index 3238cee..7287011 100644
--- a/auth0/v3/test/management/test_jobs.py
+++ b/auth0/v3/test/management/test_jobs.py
@@ -27,6 +27,18 @@ class TestJobs(unittest.TestCase):
             'https://domain/api/v2/jobs/an-id/errors',
         )
 
+    @mock.patch('auth0.v3.management.jobs.RestClient')
+    def test_export_users(self, mock_rc):
+        mock_instance = mock_rc.return_value
+
+        j = Jobs(domain='domain', token='jwttoken')
+        j.export_users({'connection_id': 'cxn_id', 'format': 'json'})
+
+        mock_instance.post.assert_called_with(
+            'https://domain/api/v2/jobs/users-exports',
+            data={'connection_id': 'cxn_id', 'format': 'json'}
+        )
+
     @mock.patch('auth0.v3.management.jobs.RestClient')
     def test_import_users(self, mock_rc):
         mock_instance = mock_rc.return_value
Repository: auth0/auth0-python
Pull request #122 (2018-10-01 15:43:02)

Implemented delete_user_by_email and test for connections
For #121 


Patch:
diff --git a/auth0/v3/management/connections.py b/auth0/v3/management/connections.py
index 95cc4c4..d2bcc65 100644
--- a/auth0/v3/management/connections.py
+++ b/auth0/v3/management/connections.py
@@ -116,3 +116,17 @@ class Connections(object):
         """
 
         return self.client.post(self._url(), data=body)
+
+    def delete_user_by_email(self, id, email):
+        """Deletes a specified connection user by its email.
+
+        Args:
+           id (str): The id of the connection (must be a database connection).
+
+           email (str): The email of the user to delete.
+
+        Returns:
+            An empty dict.
+        """
+        return self.client.delete(self._url(id) + '/users', params={'email': email})
+


Test patch:
diff --git a/auth0/v3/test/management/test_connections.py b/auth0/v3/test/management/test_connections.py
index 2b9a829..130c5c7 100644
--- a/auth0/v3/test/management/test_connections.py
+++ b/auth0/v3/test/management/test_connections.py
@@ -138,3 +138,15 @@ class TestConnection(unittest.TestCase):
             'https://domain/api/v2/connections',
             data={'a': 'b', 'c': 'd'}
         )
+
+    @mock.patch('auth0.v3.management.connections.RestClient')
+    def test_delete_user_by_email(self, mock_rc):
+        mock_instance = mock_rc.return_value
+        mock_instance.delete_user_by_email.return_value = {}
+
+        c = Connections(domain='domain', token='jwttoken')
+        c.delete_user_by_email('123', 'test@example.com')
+
+        mock_instance.delete.assert_called_with(
+            'https://domain/api/v2/connections/123/users',
+            params={'email': 'test@example.com'})
Repository: auth0/auth0-python
Pull request #167 (2018-11-05 21:15:24)

Stop lower-casing email on user search
Per the documentation here:
https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email

> If Auth0 is the identify provider (idP), the email address associated with a user is saved in lower case, regardless of how you initially provided it. For example, if you register a user as JohnSmith@example.com, Auth0 saves the user's email as johnsmith@example.com.
> 
> **In cases where Auth0 is not the idP, the `email` is stored based on the rules of idP, so make sure the search is made using the correct capitalization.**


Patch:
diff --git a/auth0/v3/management/users_by_email.py b/auth0/v3/management/users_by_email.py
index 0c92e6a..24622a9 100644
--- a/auth0/v3/management/users_by_email.py
+++ b/auth0/v3/management/users_by_email.py
@@ -39,7 +39,7 @@ class UsersByEmail(object):
         See: https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email
         """
         params = {
-            'email': email.lower(),
+            'email': email,
             'fields': fields and ','.join(fields) or None,
             'include_fields': str(include_fields).lower()
         }


Test patch:
diff --git a/auth0/v3/test/management/test_users_by_email.py b/auth0/v3/test/management/test_users_by_email.py
index 012c597..2c6e9af 100644
--- a/auth0/v3/test/management/test_users_by_email.py
+++ b/auth0/v3/test/management/test_users_by_email.py
@@ -16,7 +16,7 @@ class TestUsersByEmail(unittest.TestCase):
 
         self.assertEqual('https://domain/api/v2/users-by-email', args[0])
         self.assertEqual(kwargs['params'], {
-            'email': 'a@b.com',
+            'email': 'A@B.com',
             'fields': None,
             'include_fields': 'true'
         })
Repository: auth0/auth0-python
Pull request #170 (2018-11-23 20:15:11)

Add Revoke Refresh Token endpoint
Closes https://github.com/auth0/auth0-python/issues/115


Patch:
diff --git a/auth0/v3/authentication/revoke_token.py b/auth0/v3/authentication/revoke_token.py
new file mode 100644
index 0000000..1705bb1
--- /dev/null
+++ b/auth0/v3/authentication/revoke_token.py
@@ -0,0 +1,37 @@
+from .base import AuthenticationBase
+
+
+class RevokeToken(AuthenticationBase):
+
+    """Revoke Refresh Token endpoint
+
+    Args:
+        domain (str): Your auth0 domain (e.g: username.auth0.com)
+    """
+
+    def revoke_refresh_token(self, client_id, token, client_secret=None):
+        """Revokes a Refresh Token if it has been compromised
+           
+           Each revocation request invalidates not only the specific token, but all other tokens 
+           based on the same authorization grant. This means that all Refresh Tokens that have 
+           been issued for the same user, application, and audience will be revoked.
+
+           Args:
+                client_id (str): The Client ID for your Application
+
+                token (str): The Refresh Token you want to revoke
+
+                client_secret (str, optional): The Client Secret for your Application.
+                        Required for confidential applications.
+                        See: https://auth0.com/docs/applications/application-types#confidential-applications
+            
+            See: https://auth0.com/docs/api/authentication#refresh-token
+        """
+        body = {
+            'client_id': client_id,
+            'token': token,
+            'client_secret': client_secret
+        }
+
+        return self.post(
+            'https://{}/oauth/revoke'.format(self.domain), data=body)


Test patch:
diff --git a/auth0/v3/test/authentication/test_revoke_token.py b/auth0/v3/test/authentication/test_revoke_token.py
new file mode 100644
index 0000000..0aa40fd
--- /dev/null
+++ b/auth0/v3/test/authentication/test_revoke_token.py
@@ -0,0 +1,38 @@
+import unittest
+import mock
+from ...authentication.revoke_token import RevokeToken
+
+
+class TestRevokeToken(unittest.TestCase):
+
+    @mock.patch('auth0.v3.authentication.revoke_token.RevokeToken.post')
+    def test_revoke_refresh_token(self, mock_post):
+
+        a = RevokeToken('my.domain.com')
+
+        # regular apps
+        a.revoke_refresh_token(client_id='cid',
+                    token='tkn')
+
+        args, kwargs = mock_post.call_args
+
+        self.assertEqual(args[0], 'https://my.domain.com/oauth/revoke')
+        self.assertEqual(kwargs['data'], {
+            'client_id': 'cid',
+            'token': 'tkn',
+            'client_secret': None
+        })
+
+        # confidential apps
+        a.revoke_refresh_token(client_id='cid',
+                    token='tkn',
+                    client_secret='sh!')
+
+        args, kwargs = mock_post.call_args
+
+        self.assertEqual(args[0], 'https://my.domain.com/oauth/revoke')
+        self.assertEqual(kwargs['data'], {
+            'client_id': 'cid',
+            'token': 'tkn',
+            'client_secret': 'sh!'
+        })
Repository: auth0/auth0-python
Pull request #185 (2019-04-04 14:53:45)

Remove default value for search_engine
### Changes

Search engine v2 is no longer available for new tenants. This caused frustration for those using this library without passing a specific value for the `search_engine` feature when querying for users.

This PR removes the default value of `v1` (even older, and already disabled a long time ago). This way, those not specifying a value will default to the backend's latest version. Currently v3.

Those already passing a fixed value will see no effect.

### References

> User search v2 has been deprecated as of June 6th 2018. Tenants created after this date will not have the option of using it. We recommend that you use User Search v3 instead.

https://auth0.com/docs/users/search/v2
https://auth0.com/docs/users/search/v3

### Testing

- [x] This change adds unit test coverage
- [ ] This change adds integration test coverage
- [x] This change has been tested on the latest version of the platform/language or why not

### Checklist

- [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [x] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [x] All existing and new tests complete without errors



Patch:
diff --git a/auth0/v3/management/users.py b/auth0/v3/management/users.py
index 6640e5e..396d73c 100644
--- a/auth0/v3/management/users.py
+++ b/auth0/v3/management/users.py
@@ -25,7 +25,7 @@ class Users(object):
         return url
 
     def list(self, page=0, per_page=25, sort=None, connection=None, q=None,
-             search_engine='v1', include_totals=True, fields=None,
+             search_engine=None, include_totals=True, fields=None,
              include_fields=True):
         """List or search users.
 
@@ -43,8 +43,9 @@ class Users(object):
                 in app_metadata, user_metadata or the normalized user profile
                 are searchable.
 
-            search_engine (str, optional): Use 'v2' if you want to try our new
-                search engine.
+            search_engine (str, optional): The version of the search_engine to use
+                when querying for users. Will default to the latest version available.
+                See: https://auth0.com/docs/users/search
 
             fields (list of str, optional): A list of fields to include or
                 exclude from the result (depending on include_fields). Empty to


Test patch:
diff --git a/auth0/v3/test/management/test_users.py b/auth0/v3/test/management/test_users.py
index b13f600..36a5757 100644
--- a/auth0/v3/test/management/test_users.py
+++ b/auth0/v3/test/management/test_users.py
@@ -24,7 +24,7 @@ class TestUsers(unittest.TestCase):
             'fields': None,
             'include_fields': 'true',
             'q': None,
-            'search_engine': 'v1'
+            'search_engine': None
         })
 
         u.list(page=1, per_page=50, sort='s', connection='con', q='q',
Repository: auth0/auth0-python
Pull request #191 (2019-05-02 18:44:20)

Fix HTTP method used for rotating Client secret
### Changes

The rotate client secret endpoint expects a POST request, not a GET. This PR fixes it.

### References

Will close https://github.com/auth0/auth0-python/issues/189

### Testing

- [x] This change adds unit test coverage
- [x] This change adds integration test coverage
- [x] This change has been tested on the latest version of the platform/language or why not

### Checklist

- [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [x] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [x] All existing and new tests complete without errors



Patch:
diff --git a/auth0/v3/management/clients.py b/auth0/v3/management/clients.py
index a69dfa6..c014217 100644
--- a/auth0/v3/management/clients.py
+++ b/auth0/v3/management/clients.py
@@ -129,7 +129,7 @@ class Clients(object):
               See: https://auth0.com/docs/api/management/v2#!/Clients/post_rotate_secret
         """
 
-        params = {'id': id }
+        data = {'id': id }
 
         url = self._url('%s/rotate-secret' % id)
-        return self.client.get(url, params=params)
\ No newline at end of file
+        return self.client.post(url, data=data)
\ No newline at end of file


Test patch:
diff --git a/auth0/v3/test/management/test_clients.py b/auth0/v3/test/management/test_clients.py
index ae9d5e5..4e4c10e 100644
--- a/auth0/v3/test/management/test_clients.py
+++ b/auth0/v3/test/management/test_clients.py
@@ -119,8 +119,8 @@ class TestClients(unittest.TestCase):
         c = Clients(domain='domain', token='jwttoken')
         c.rotate_secret('this-id')
 
-        mock_instance.get.assert_called_with(
-            'https://domain/api/v2/clients/this-id/rotate-secret', params={'id': 'this-id'}
+        mock_instance.post.assert_called_with(
+            'https://domain/api/v2/clients/this-id/rotate-secret', data={'id': 'this-id'}
         )
Repository: auth0/auth0-python
Pull request #248 (2020-11-25 23:00:12)

Adds a new user method invalidate_remembered_browsers
### Changes

Please describe both what is changing and why this is important. Include:

- Adds a missing endpoint to invalidate all remembered browsers (mfa) for a user

### References

https://auth0.com/docs/api/management/v2#!/Users/post_invalidate_remember_browser

### Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors. 

- [x] This change adds unit test coverage
- [ ] This change adds integration test coverage
- [ ] This change has been tested on the latest version of the platform/language or why not

### Checklist

- [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [x] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [x] All existing and new tests complete without errors


kpurdon: @lbalmaceda from issues it looks like your the correct person to check in with on this (LMK if that's not the case). Anything I can do to get this reviewed? Thanks!

Patch:
diff --git a/auth0/v3/management/users.py b/auth0/v3/management/users.py
index d90c5a4..c5663ad 100644
--- a/auth0/v3/management/users.py
+++ b/auth0/v3/management/users.py
@@ -353,3 +353,15 @@ class Users(object):
 
         url = self._url('{}/logs'.format(user_id))
         return self.client.get(url, params=params)
+
+    def invalidate_remembered_browsers(self, user_id):
+        """Invalidate all remembered browsers across all authentication factors for a user.
+
+        Args:
+            user_id (str):  The user_id to invalidate remembered browsers for.
+
+        See: https://auth0.com/docs/api/management/v2#!/Users/post_invalidate_remember_browser
+        """
+
+        url = self._url('{}/multifactor/actions/invalidate-remember-browser'.format(user_id))
+        return self.client.post(url)


Test patch:
diff --git a/auth0/v3/test/management/test_users.py b/auth0/v3/test/management/test_users.py
index fc9bc10..359876e 100644
--- a/auth0/v3/test/management/test_users.py
+++ b/auth0/v3/test/management/test_users.py
@@ -293,3 +293,13 @@ class TestUsers(unittest.TestCase):
         self.assertEqual(kwargs['params']['per_page'], 50)
         self.assertIsNone(kwargs['params']['sort'])
         self.assertEqual(kwargs['params']['include_totals'], 'false')
+
+    @mock.patch('auth0.v3.management.users.RestClient')
+    def test_invalidate_remembered_browsers(self, mock_rc):
+        mock_instance = mock_rc.return_value
+
+        u = Users(domain='domain', token='jwttoken')
+        u.invalidate_remembered_browsers('user-id')
+
+        args, kwargs = mock_instance.post.call_args
+        self.assertEqual('https://domain/api/v2/users/user-id/multifactor/actions/invalidate-remember-browser', args[0])
Repository: auth0/auth0-python
Pull request #269 (2021-04-19 02:00:03)

Repair Organisation get by name URL.
### Changes

Please describe both what is changing and why this is important. Include:

- Endpoints added, deleted, deprecated, or changed
There is an error in `organizations.get_organization_by_name`. The path from the docs should be `/api/v2/organizations/name/{name}`. The current implementation, however, just uses the default `/api/v2/organizations` and sends the `name` parameter (which is invalid and throws an error).

### References

Please include relevant links supporting this change such as a:

- Pull request https://github.com/auth0/auth0-python/issues/268
- [API documentation](https://auth0.com/docs/api/management/v2#!/Organizations/get_name_by_name)

### Testing

- [ ] This change adds unit test coverage
- [ ] This change adds integration test coverage
- [x] This change has been tested on the latest version of the platform/language or why not

I'm sorry but I can't see how to run the existing test. Please point me to the instructions and I'll update the PR.

### Checklist

- [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
- [x] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
- [x] All existing and new tests complete without errors



Patch:
diff --git a/auth0/v3/management/organizations.py b/auth0/v3/management/organizations.py
index bbb72e9..16a9b53 100644
--- a/auth0/v3/management/organizations.py
+++ b/auth0/v3/management/organizations.py
@@ -58,10 +58,9 @@ class Organizations(object):
         See: https://auth0.com/docs/api/management/v2#!/Organizations/get_name_by_name
         """
         params = {}
-        params['name'] = name
 
-        return self.client.get(self._url(), params=params)
-    
+        return self.client.get(self._url('name', name), params=params)
+
     def get_organization(self, id):
         """Retrieves an organization by its ID.
 


Test patch:
diff --git a/auth0/v3/test/management/test_organizations.py b/auth0/v3/test/management/test_organizations.py
index babb7fe..0c8219b 100644
--- a/auth0/v3/test/management/test_organizations.py
+++ b/auth0/v3/test/management/test_organizations.py
@@ -45,8 +45,8 @@ class TestOrganizations(unittest.TestCase):
 
         args, kwargs = mock_instance.get.call_args
 
-        self.assertEqual('https://domain/api/v2/organizations', args[0])
-        self.assertEqual(kwargs['params'], {'name': 'test-org'})
+        self.assertEqual('https://domain/api/v2/organizations/name/test-org', args[0])
+        self.assertEqual(kwargs['params'], {})
 
     @mock.patch('auth0.v3.management.organizations.RestClient')
     def test_get_organization(self, mock_rc):