forked from capless/warrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request capless#70 from capless/armicron_fix_signup
Fixed signup, fixed tests.
- Loading branch information
Showing
3 changed files
with
77 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,22 +129,39 @@ u = Cognito('your-user-pool-id','your-client-id', | |
|
||
Register a user to the user pool | ||
|
||
**Important:** The keyword arguments used for this method depend on your user pool's configuration, and make sure the client id (app id) used has write permissions for the attriubtes you are trying to create. Example, if you want to create a user with a given_name equal to Johnson make sure the client_id you're using has permissions to edit or create given_name for a user in the pool. | ||
**Important:** The arguments for `add_base_attributes` and `add_custom_attributes` methods depend on your user pool's configuration, and make sure the client id (app id) used has write permissions for the attriubtes you are trying to create. Example, if you want to create a user with a given_name equal to Johnson make sure the client_id you're using has permissions to edit or create given_name for a user in the pool. | ||
|
||
|
||
```python | ||
from warrant import Cognito | ||
|
||
u = Cognito('your-user-pool-id', 'your-client-id') | ||
|
||
u.register('username', 'password', email='[email protected]', some_random_attr='random value') # **kwargs are the other attributes that should be set ex. email, given_name, family_name | ||
u.add_base_attributes(email='[email protected]', some_random_attr='random value') | ||
|
||
u.register('username', 'password') | ||
``` | ||
|
||
Register with custom attributes. | ||
|
||
Firstly, add custom attributes on 'General settings -> Attributes' page. | ||
Secondly, set permissions on 'Generals settings-> App clients-> Show details-> Set attribute read and write permissions' page. | ||
```python | ||
from warrant import Cognito | ||
|
||
u = Cognito('your-user-pool-id', 'your-client-id') | ||
|
||
u.add_base_attributes(email='[email protected]', some_random_attr='random value') | ||
|
||
u.add_custom_attributes(state='virginia', city='Centreville') | ||
|
||
u.register('username', 'password') | ||
``` | ||
##### Arguments | ||
|
||
- **username:** User Pool username | ||
- **password:** User Pool password | ||
- **attr_map:** Attribute map to Cognito's attributes | ||
- **kwargs:** Additional User Pool attributes ex. `**{'email':'[email protected]'}` | ||
|
||
|
||
#### Authenticate #### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,15 +90,16 @@ def test_verify_token(self): | |
# self.assertEqual(self.user.access_token,None) | ||
|
||
@patch('warrant.Cognito', autospec=True) | ||
def test_register(self,cognito_user): | ||
def test_register(self, cognito_user): | ||
u = cognito_user(self.cognito_user_pool_id, self.app_id, | ||
username=self.username) | ||
res = u.register('sampleuser','sample4#Password', | ||
given_name='Brian',family_name='Jones', | ||
name='Brian Jones', | ||
email='[email protected]', | ||
phone_number='+19194894555',gender='Male', | ||
preferred_username='billyocean') | ||
u.add_base_attributes( | ||
given_name='Brian', family_name='Jones', | ||
name='Brian Jones', email='[email protected]', | ||
phone_number='+19194894555', gender='Male', | ||
preferred_username='billyocean') | ||
res = u.register('sampleuser', 'sample4#Password') | ||
|
||
#TODO: Write assumptions | ||
|
||
|
||
|