getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.64k stars 2.05k forks source link

Cognito - No validation that there isn't already an existing user with the same username in admin_update_user_attributes #5271

Closed JorisLimousin closed 1 year ago

JorisLimousin commented 2 years ago

Hi,

Sorry for the spam, just raising another issue for a potential enhancement. There is currently no validation on the admin_update_user_attributes function to check that the email address we are trying to update for a user isn't going to cause a conflict.

If you try to update the email address of a user to one that already exists in the user pool, a ClientError exception should be raised with the code AliasExistsException.

This piece of code should raise the exception:

cognito_client.admin_update_user_attributes(
      UserPoolId=user_pool_id,
      Username=user_sub,
      UserAttributes=[{"Name": "email", "Value": email_address_of_existing_user}],
)

Considering how bad the Cognito service is, I have a feeling it might be dependent on the configuration of the User Pool and won't always raise an exception depending on how it's configured. You might require your user pool to be configured with the following to throw this type of exception: UsernameAttributes=["email"]. Not 100% sure though.

bblommers commented 2 years ago

All good @JorisLimousin - every enhancement is useful!

ArpanShah2k commented 2 years ago

hi, I am interested in fixing this issue. it will be a great opportunity to fix this issue and contribute to this project if you assign me this issue . @JorisLimousin @bblommers @corasaurus-hex @olleolleolle @JackDanger

bblommers commented 2 years ago

Done @ArpanShah2k! We have some documentation on how to get started: http://docs.getmoto.org/en/latest/docs/contributing/index.html Please let us know if you run into any issues.

ArpanShah2k commented 2 years ago

Thank you sir for your kind consideration. I will go through this documentation and start working on the enhancement. I'll approach if I need help.

ArpanShah2k commented 2 years ago

Respected sir, I have read the documentation and all. but i am facing issues in installation of moto in my laptop.

the path i went through is : 1) install python 3.10.8 will all its dependencies like pip, idle , etc. 2) install docker ( facing issues). 2) set path in cmd. 3) run commands in python and cmd to install moto. ( facing issues).

can you please help me out with this .

On Mon, Sep 12, 2022 at 2:55 PM Bert Blommers @.***> wrote:

Done @ArpanShah2k https://github.com/ArpanShah2k! We have some documentation on how to get started: http://docs.getmoto.org/en/latest/docs/contributing/index.html Please let us know if you run into any issues.

— Reply to this email directly, view it on GitHub https://github.com/spulec/moto/issues/5271#issuecomment-1243459147, or unsubscribe https://github.com/notifications/unsubscribe-auth/A273YZPKO2VUVT32HCMM27DV53ZJJANCNFSM5Z7NX44A . You are receiving this because you were mentioned.Message ID: @.***>

-- The information contained in this electronic communication is intended solely for the individual(s) or entity to which it is addressed. It may contain proprietary, confidential and/or legally privileged information. Any review, retransmission, dissemination, printing, copying or other use of, or taking any action in reliance on the contents of this information by person(s) or entities other than the intended recipient is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us by responding to this email or telephone and immediately and permanently delete all copies of this message and any attachments from your system(s). The contents of this message do not necessarily represent the views or policies of BITS Pilani.

bblommers commented 2 years ago

Don't worry about the Docker issues @ArpanShah2k - a working Docker installation is not a requirement for Cognito. (Only for other services.)

3) run commands in python and cmd to install moto. ( facing issues).

Just to verify: you have forked Moto, and checked out your copy, before installing?

Which commands are you running, and what are the errors that you see?

ArpanShah2k commented 2 years ago

I have solved

Don't worry about the Docker issues @ArpanShah2k - a working Docker installation is not a requirement for Cognito. (Only for other services.)

  1. run commands in python and cmd to install moto. ( facing issues).

Just to verify: you have forked Moto, and checked out your copy, before installing?

Which commands are you running, and what are the errors that you see?

I have solved this errors that i was getting while setup now.

ArpanShah2k commented 1 year ago

sir i have created PR for this Issue. I request you to review it and merge it if all the test cases are cleared.