示例#1
0
    def validate_params(self):
        # 認証・ウォレット情報が登録済であること
        UserUtil.verified_phone_and_email(self.event)
        UserUtil.validate_private_eth_address(
            self.dynamodb, self.event['requestContext']['authorizer']['claims']
            ['cognito:username'])
        # single
        validate(self.params, self.get_schema())
        # 署名が正しいこと
        if self.params.get('init_approve_signed_transaction') is not None:
            PrivateChainUtil.validate_raw_transaction_signature(
                self.params['init_approve_signed_transaction'],
                self.event['requestContext']['authorizer']['claims']
                ['custom:private_eth_address'])
        PrivateChainUtil.validate_raw_transaction_signature(
            self.params['approve_signed_transaction'],
            self.event['requestContext']['authorizer']['claims']
            ['custom:private_eth_address'])
        PrivateChainUtil.validate_raw_transaction_signature(
            self.params['relay_signed_transaction'],
            self.event['requestContext']['authorizer']['claims']
            ['custom:private_eth_address'])

        # pinコードを検証
        self.__validate_pin_code(self.params['access_token'],
                                 self.params['pin_code'])
    def validate_params(self):
        UserUtil.verified_phone_and_email(self.event)

        # カストディ規制時のウォレット移行が済んでいなければ利用不可
        user_id = self.event['requestContext']['authorizer']['claims'][
            'cognito:username']
        UserUtil.validate_private_eth_address(self.dynamodb, user_id)
    def validate_params(self):
        # 認証・ウォレット情報が登録済であること
        UserUtil.verified_phone_and_email(self.event)
        UserUtil.validate_private_eth_address(
            self.dynamodb, self.event['requestContext']['authorizer']['claims']
            ['cognito:username'])

        # single
        validate(self.params, self.get_schema())
        # 署名が正しいこと
        PrivateChainUtil.validate_raw_transaction_signature(
            self.params['purchase_signed_transaction'],
            self.event['requestContext']['authorizer']['claims']
            ['custom:private_eth_address'])
        PrivateChainUtil.validate_raw_transaction_signature(
            self.params['burn_signed_transaction'],
            self.event['requestContext']['authorizer']['claims']
            ['custom:private_eth_address'])

        # relation
        DBUtil.validate_article_existence(self.dynamodb,
                                          self.params['article_id'],
                                          status='public',
                                          is_purchased=True)
        DBUtil.validate_not_purchased(
            self.dynamodb, self.params['article_id'],
            self.event['requestContext']['authorizer']['claims']
            ['cognito:username'])
 def test_validate_private_eth_address_ng_not_exists_private_eth_address(
         self):
     with self.assertRaises(NotAuthorizedError) as e:
         test_user = '******'
         UserUtil.validate_private_eth_address(self.dynamodb, test_user)
     self.assertEqual(e.exception.args[0], 'Not exists private_eth_address')
 def test_validate_private_eth_address_ok(self):
     test_user = '******'
     # 例外が発生しないこと
     UserUtil.validate_private_eth_address(self.dynamodb, test_user)