def test_when_wallet_exists(self):
        os.environ['BETA_MODE_FLAG'] = "0"

        # すでに `custom:private_eth_address` を持っている場合
        # パスワード再発行時にこのような値が渡される
        event = {
            'userName': '******',
            'request': {
                'userAttributes': {
                    'phone_number':
                    '',
                    'email':
                    '*****@*****.**',
                    "custom:private_eth_address":
                    "0x5d7743a4a6f21593ff6d3d81595f270123456789"
                }
            }
        }
        postconfirmation = PostConfirmation(event=event,
                                            context="",
                                            dynamodb=dynamodb)

        # `custom:private_eth_address` は更新されないこと
        # (LocalStackがCognito対応していないため、MagicMockで設定した例外がスローされないことで検証を担保している)
        self.assertEqual(postconfirmation.main(), True)
        table = dynamodb.Table(os.environ['USERS_TABLE_NAME'])
        items = table.get_item(Key={"user_id": "foobar"})
        self.assertEqual(items['Item']['user_id'],
                         items['Item']['user_display_name'])
Пример #2
0
 def test_ok_with_confirm_forgot_password(self):
     os.environ['BETA_MODE_FLAG'] = "0"
     event = {
             'userName': '******',
             'triggerSource': 'PostConfirmation_ConfirmForgotPassword',
     }
     post_confirmation = PostConfirmation(event=event, context="", dynamodb=dynamodb)
     self.assertEqual(post_confirmation.main(), True)
     table = dynamodb.Table(os.environ['USERS_TABLE_NAME'])
     items = table.get_item(Key={"user_id": "hogehoge"})
     self.assertIsNone(items.get('Item'))
 def test_create_userid_already_exists(self):
     os.environ['BETA_MODE_FLAG'] = "0"
     event = {
             'userName': '******',
             'request': {
                 'userAttributes': {
                     'phone_number': '',
                     'email': '*****@*****.**'
                 }
             }
     }
     postconfirmation = PostConfirmation(event=event, context="", dynamodb=dynamodb)
     response = postconfirmation.main()
     self.assertEqual(response['statusCode'], 500)
 def test_beta_user_confirm(self):
     os.environ['BETA_MODE_FLAG'] = "1"
     event = {
             'userName': '******',
             'request': {
                 'userAttributes': {
                     'phone_number': '',
                     'email': '*****@*****.**'
                 }
             }
     }
     postconfirmation = PostConfirmation(event=event, context="", dynamodb=dynamodb)
     response = postconfirmation.main()
     table = dynamodb.Table(os.environ['BETA_USERS_TABLE_NAME'])
     items = table.get_item(Key={"email": "*****@*****.**"})
     self.assertEqual(items['Item']['used'], True)
 def test_create_userid(self):
     os.environ['BETA_MODE_FLAG'] = "0"
     event = {
             'userName': '******',
             'request': {
                 'userAttributes': {
                     'phone_number': '',
                     'email': '*****@*****.**'
                 }
             }
     }
     postconfirmation = PostConfirmation(event=event, context="", dynamodb=dynamodb)
     self.assertEqual(postconfirmation.main(), True)
     table = dynamodb.Table(os.environ['USERS_TABLE_NAME'])
     items = table.get_item(Key={"user_id": "hogehoge"})
     self.assertEqual(items['Item']['user_id'], items['Item']['user_display_name'])
    def test_when_wallet_not_exists(self):
        os.environ['BETA_MODE_FLAG'] = "0"

        # まだ `custom:private_eth_address` を持っていない場合
        # ユーザ新規作成時にこのような値が渡される
        event = {
            'userName': '******',
            'request': {
                'userAttributes': {
                    'phone_number': '',
                    'email': '*****@*****.**'
                }
            }
        }
        postconfirmation = PostConfirmation(event=event, context="", dynamodb=dynamodb)

        # `custom:private_eth_address` はが更新されること
        # (LocalStackがCognito対応していないため、MagicMockで設定した例外がスローされることで検証を担保している)
        with self.assertRaises(Exception):
            self.assertEqual(postconfirmation.main(), True)
Пример #7
0
 def test_create_userid_already_exists(self):
     os.environ['BETA_MODE_FLAG'] = "0"
     event = {
             'userName': '******',
             'request': {
                 'userAttributes': {
                     'phone_number': '',
                     'email': '*****@*****.**'
                 }
             }
     }
     with self.assertRaises(Exception) as e:
         PostConfirmation(event=event, context="", dynamodb=dynamodb).main()
     self.assertEqual(e.exception.args[0], 'Internal server error')
Пример #8
0
def lambda_handler(event, context):
    postconfirmation = PostConfirmation(event=event, context=context, dynamodb=dynamodb, cognito=cognito)
    postconfirmation.main()
    return event