From ce1964c3f60faeab30dff8552da4a8a044f39bf3 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 16:56:28 +0900 Subject: [PATCH 1/8] fix tests --- .../publish/test_me_articles_drafts_publish.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py b/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py index b4b659d6..4159a72b 100644 --- a/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py +++ b/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py @@ -142,7 +142,6 @@ def test_main_ok(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -195,7 +194,6 @@ def test_main_ok_with_article_content_edit(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -244,7 +242,6 @@ def test_main_ok_article_history_arleady_exists(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -295,7 +292,6 @@ def test_create_and_count_raise_exception(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -321,7 +317,6 @@ def test_call_tag_util_methods(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -363,7 +358,6 @@ def test_call_validate_array_unique(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -395,7 +389,6 @@ def test_call_validate_methods(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -451,7 +444,6 @@ def test_validation_with_no_article_id(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -474,7 +466,6 @@ def test_validation_article_id_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -497,7 +488,6 @@ def test_validation_article_id_min(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -518,7 +508,6 @@ def test_validation_with_no_topic(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -542,7 +531,6 @@ def test_validation_topic_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -566,7 +554,6 @@ def test_validation_many_tags(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -590,7 +577,6 @@ def test_validation_tag_name_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -614,7 +600,6 @@ def test_validation_tag_name_min(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } From f10738276a52102fc7a005478b982dc43e105466 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 17:29:22 +0900 Subject: [PATCH 2/8] fix tests --- .../test_me_articles_drafts_publish.py | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py b/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py index 4159a72b..76ee3f8c 100644 --- a/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py +++ b/tests/handlers/me/articles/drafts/publish/test_me_articles_drafts_publish.py @@ -1,6 +1,5 @@ import json import os -import boto3 import time from elasticsearch import Elasticsearch @@ -17,7 +16,7 @@ class TestMeArticlesDraftsPublish(TestCase): - dynamodb = boto3.resource('dynamodb', endpoint_url='http://localhost:4569/') + dynamodb = TestsUtil.get_dynamodb_client() elasticsearch = Elasticsearch( hosts=[{'host': 'localhost'}] ) @@ -109,6 +108,14 @@ def setUp(self): TestsUtil.create_table(self.dynamodb, os.environ['SCREENED_ARTICLE_TABLE_NAME'], []) + user_configurations_items = [ + { + 'user_id': 'test01', + 'private_eth_address': '0x1234567890123456789012345678901234567890' + }, + ] + TestsUtil.create_table(self.dynamodb, os.environ['USER_CONFIGURATIONS_TABLE_NAME'], user_configurations_items) + TestsEsUtil.create_tag_index(self.elasticsearch) self.elasticsearch.indices.refresh(index="tags") @@ -162,7 +169,8 @@ def test_main_ok(self): self.assertEqual(response['statusCode'], 200) - article_info = self.article_info_table.get_item(Key={'article_id': params['pathParameters']['article_id']})['Item'] + article_info = self.article_info_table.get_item(Key={'article_id': params['pathParameters']['article_id']})[ + 'Item'] article_content = self.article_content_table.get_item( Key={'article_id': params['pathParameters']['article_id']} )['Item'] @@ -212,7 +220,8 @@ def test_main_ok_with_article_content_edit(self): article_history_after = self.article_history_table.scan()['Items'] article_content_edit_after = self.article_content_edit_table.scan()['Items'] - article_info = self.article_info_table.get_item(Key={'article_id': params['pathParameters']['article_id']})['Item'] + article_info = self.article_info_table.get_item(Key={'article_id': params['pathParameters']['article_id']})[ + 'Item'] article_content = self.article_content_table.get_item( Key={'article_id': params['pathParameters']['article_id']} )['Item'] @@ -260,7 +269,8 @@ def test_main_ok_article_history_arleady_exists(self): article_history_after = self.article_history_table.scan()['Items'] article_content_edit_after = self.article_content_edit_table.scan()['Items'] - article_info = self.article_info_table.get_item(Key={'article_id': params['pathParameters']['article_id']})['Item'] + article_info = self.article_info_table.get_item(Key={'article_id': params['pathParameters']['article_id']})[ + 'Item'] article_content = self.article_content_table.get_item( Key={'article_id': params['pathParameters']['article_id']} )['Item'] @@ -422,7 +432,7 @@ def test_validation_not_exists_private_eth_address(self): 'requestContext': { 'authorizer': { 'claims': { - 'cognito:username': 'test01', + 'cognito:username': 'no_eth_address_user', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -431,8 +441,8 @@ def test_validation_not_exists_private_eth_address(self): } params['body'] = json.dumps(params['body']) response = MeArticlesDraftsPublish(params, {}, dynamodb=self.dynamodb, elasticsearch=self.elasticsearch).main() - self.assertEqual(response['statusCode'], 400) - self.assertEqual(response['body'], '{"message": "Invalid parameter: not exists private_eth_address"}') + self.assertEqual(response['statusCode'], 403) + self.assertEqual(response['body'], '{"message": "Not exists private_eth_address"}') def test_validation_with_no_article_id(self): params = { From 94359896c6c9619e96a984797c2512134d734b6c Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 17:29:51 +0900 Subject: [PATCH 3/8] fix --- .../articles/drafts/publish/me_articles_drafts_publish.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py b/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py index 46859ab2..29f9e8bd 100644 --- a/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py +++ b/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py @@ -30,8 +30,8 @@ def get_schema(self): def validate_params(self): UserUtil.verified_phone_and_email(self.event) - if self.event['requestContext']['authorizer']['claims'].get('custom:private_eth_address') is None: - raise ValidationError('not exists private_eth_address') + UserUtil.validate_private_eth_address(self.dynamodb, + self.event['requestContext']['authorizer']['claims']['cognito:username']) validate(self.params, self.get_schema()) @@ -81,7 +81,8 @@ def exec_main_proc(self): def __delete_article_content_edit(self): article_content_edit_table = self.dynamodb.Table(os.environ['ARTICLE_CONTENT_EDIT_TABLE_NAME']) - article_content_edit = article_content_edit_table.get_item(Key={'article_id': self.params['article_id']}).get('Item') + article_content_edit = article_content_edit_table.get_item(Key={'article_id': self.params['article_id']}).get( + 'Item') if article_content_edit: article_content_edit_table.delete_item(Key={'article_id': self.params['article_id']}) From bf7b399ae0e91a12348f8bed4507de67d206d0e0 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 18:29:43 +0900 Subject: [PATCH 4/8] fix --- .../me/articles/drafts/publish/me_articles_drafts_publish.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py b/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py index 29f9e8bd..e76d953c 100644 --- a/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py +++ b/src/handlers/me/articles/drafts/publish/me_articles_drafts_publish.py @@ -8,7 +8,7 @@ from boto3.dynamodb.conditions import Key from lambda_base import LambdaBase -from jsonschema import validate, ValidationError +from jsonschema import validate from db_util import DBUtil from parameter_util import ParameterUtil from tag_util import TagUtil From c4d9565e1c2775585fe3870dd972e35cdb8b1858 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 18:45:01 +0900 Subject: [PATCH 5/8] fix test --- .../create/test_me_articles_like_create.py | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/handlers/me/articles/like/create/test_me_articles_like_create.py b/tests/handlers/me/articles/like/create/test_me_articles_like_create.py index 286c27dd..afb5c0f0 100644 --- a/tests/handlers/me/articles/like/create/test_me_articles_like_create.py +++ b/tests/handlers/me/articles/like/create/test_me_articles_like_create.py @@ -107,6 +107,26 @@ def setUp(self): self.unread_notification_manager_items ) + user_configurations_items = [ + { + 'user_id': 'test01', + 'private_eth_address': '0x1234567890123456789012345678901234567890' + }, + { + 'user_id': 'test05', + 'private_eth_address': '0x1234567890123456789012345678901234567891' + }, + { + 'user_id': 'test06', + 'private_eth_address': '0x1234567890123456789012345678901234567892' + }, + { + 'user_id': 'article_user_id_02', + 'private_eth_address': '0x1234567890123456789012345678901234567893' + }, + ] + TestsUtil.create_table(self.dynamodb, os.environ['USER_CONFIGURATIONS_TABLE_NAME'], user_configurations_items) + def tearDown(self): TestsUtil.delete_all_tables(self.dynamodb) @@ -126,7 +146,6 @@ def test_main_ok_exist_article_id(self): 'authorizer': { 'claims': { 'cognito:username': 'test05', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -181,7 +200,6 @@ def test_create_notification_and_unread_notification_manager(self): 'authorizer': { 'claims': { 'cognito:username': 'test06', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -233,7 +251,6 @@ def test_main_with_updating_notification(self): 'authorizer': { 'claims': { 'cognito:username': 'test06', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -275,7 +292,6 @@ def test_main_ok_with_self_liked_user(self): 'authorizer': { 'claims': { 'cognito:username': self.article_info_table_items[2]['user_id'], - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -313,7 +329,6 @@ def test_raise_exception_in_creating_notification(self): 'authorizer': { 'claims': { 'cognito:username': 'test05', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -335,7 +350,6 @@ def test_call_validate_article_existence(self): 'authorizer': { 'claims': { 'cognito:username': 'test05', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -362,7 +376,6 @@ def test_main_ng_exist_user_id(self): 'authorizer': { 'claims': { 'cognito:username': self.article_liked_user_table_items[0]['user_id'], - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -382,7 +395,7 @@ def test_validation_not_exists_private_eth_address(self): 'requestContext': { 'authorizer': { 'claims': { - 'cognito:username': self.article_liked_user_table_items[0]['user_id'], + 'cognito:username': self.article_liked_user_table_items[1]['user_id'], 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -390,8 +403,8 @@ def test_validation_not_exists_private_eth_address(self): } } response = MeArticlesLikeCreate(event=params, context={}, dynamodb=self.dynamodb).main() - self.assertEqual(response['statusCode'], 400) - self.assertEqual(response['body'], '{"message": "Invalid parameter: not exists private_eth_address"}') + self.assertEqual(response['statusCode'], 403) + self.assertEqual(response['body'], '{"message": "Not exists private_eth_address"}') def test_validation_with_no_params(self): params = {} From e60ba33129e57ed547812c59e2dbbc5715c09fe5 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 18:45:07 +0900 Subject: [PATCH 6/8] fix --- .../like/create/me_articles_like_create.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/handlers/me/articles/like/create/me_articles_like_create.py b/src/handlers/me/articles/like/create/me_articles_like_create.py index fff6a985..c539146b 100644 --- a/src/handlers/me/articles/like/create/me_articles_like_create.py +++ b/src/handlers/me/articles/like/create/me_articles_like_create.py @@ -26,8 +26,8 @@ def get_schema(self): def validate_params(self): UserUtil.verified_phone_and_email(self.event) - if self.event['requestContext']['authorizer']['claims'].get('custom:private_eth_address') is None: - raise ValidationError('not exists private_eth_address') + UserUtil.validate_private_eth_address(self.dynamodb, + self.event['requestContext']['authorizer']['claims']['cognito:username']) # single if self.event.get('pathParameters') is None: @@ -72,7 +72,8 @@ def exec_main_proc(self): def __create_like_notification(self, article_info): notification_table = self.dynamodb.Table(os.environ['NOTIFICATION_TABLE_NAME']) - notification_id = '-'.join([settings.LIKE_NOTIFICATION_TYPE, article_info['user_id'], article_info['article_id']]) + notification_id = '-'.join( + [settings.LIKE_NOTIFICATION_TYPE, article_info['user_id'], article_info['article_id']]) notification = notification_table.get_item(Key={'notification_id': notification_id}).get('Item') liked_count = self.__get_article_likes_count() @@ -91,15 +92,15 @@ def __create_like_notification(self, article_info): ) else: notification_table.put_item(Item={ - 'notification_id': notification_id, - 'user_id': article_info['user_id'], - 'article_id': article_info['article_id'], - 'article_title': article_info['title'], - 'sort_key': TimeUtil.generate_sort_key(), - 'type': settings.LIKE_NOTIFICATION_TYPE, - 'liked_count': liked_count, - 'created_at': int(time.time()) - } + 'notification_id': notification_id, + 'user_id': article_info['user_id'], + 'article_id': article_info['article_id'], + 'article_title': article_info['title'], + 'sort_key': TimeUtil.generate_sort_key(), + 'type': settings.LIKE_NOTIFICATION_TYPE, + 'liked_count': liked_count, + 'created_at': int(time.time()) + } ) def __update_unread_notification_manager(self, article_info): From 7f4ae017248e0b141ca227add10550929487af26 Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 18:54:01 +0900 Subject: [PATCH 7/8] fix test --- ..._me_articles_drafts_publish_with_header.py | 40 ++++++------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/tests/handlers/me/articles/drafts/publish_with_header/test_me_articles_drafts_publish_with_header.py b/tests/handlers/me/articles/drafts/publish_with_header/test_me_articles_drafts_publish_with_header.py index 5aab40ac..a3331e94 100644 --- a/tests/handlers/me/articles/drafts/publish_with_header/test_me_articles_drafts_publish_with_header.py +++ b/tests/handlers/me/articles/drafts/publish_with_header/test_me_articles_drafts_publish_with_header.py @@ -1,6 +1,5 @@ import json import os -import boto3 import time import settings from elasticsearch import Elasticsearch @@ -14,7 +13,7 @@ class TestMeArticlesDraftsPublishWithHeader(TestCase): - dynamodb = boto3.resource('dynamodb', endpoint_url='http://localhost:4569/') + dynamodb = TestsUtil.get_dynamodb_client() elasticsearch = Elasticsearch( hosts=[{'host': 'localhost'}] ) @@ -126,6 +125,14 @@ def setUp(self): TestsUtil.create_table(self.dynamodb, os.environ['SCREENED_ARTICLE_TABLE_NAME'], []) + user_configurations_items = [ + { + 'user_id': 'test01', + 'private_eth_address': '0x1234567890123456789012345678901234567890' + }, + ] + TestsUtil.create_table(self.dynamodb, os.environ['USER_CONFIGURATIONS_TABLE_NAME'], user_configurations_items) + TestsEsUtil.create_tag_index(self.elasticsearch) self.elasticsearch.indices.refresh(index="tags") @@ -161,7 +168,6 @@ def test_main_ok(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -216,7 +222,6 @@ def test_main_ok_with_article_content_edit(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -269,7 +274,6 @@ def test_main_ok_article_history_arleady_exists(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -321,7 +325,6 @@ def test_create_and_count_raise_exception(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -348,7 +351,6 @@ def test_call_tag_util_methods(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -391,7 +393,6 @@ def test_call_validate_array_unique(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -424,7 +425,6 @@ def test_call_validate_methods(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -469,7 +469,6 @@ def test_call_validate_img_url(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -499,7 +498,6 @@ def test_not_call_validate_img_url(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -525,7 +523,7 @@ def test_validation_not_exists_private_eth_address(self): 'requestContext': { 'authorizer': { 'claims': { - 'cognito:username': 'test01', + 'cognito:username': 'non_private_eth_address_user', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -536,8 +534,8 @@ def test_validation_not_exists_private_eth_address(self): response = MeArticlesDraftsPublishWithHeader( params, {}, dynamodb=self.dynamodb, elasticsearch=self.elasticsearch ).main() - self.assertEqual(response['statusCode'], 400) - self.assertEqual(response['body'], '{"message": "Invalid parameter: not exists private_eth_address"}') + self.assertEqual(403, response['statusCode']) + self.assertEqual('{"message": "Not exists private_eth_address"}', response['body']) def test_validation_with_no_article_id(self): params = { @@ -549,7 +547,6 @@ def test_validation_with_no_article_id(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -572,7 +569,6 @@ def test_validation_article_id_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -595,7 +591,6 @@ def test_validation_article_id_min(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -616,7 +611,6 @@ def test_validation_with_no_topic(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -640,7 +634,6 @@ def test_validation_topic_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -664,7 +657,6 @@ def test_validation_many_tags(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -688,7 +680,6 @@ def test_validation_tag_name_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -712,7 +703,6 @@ def test_validation_tag_name_min(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -738,7 +728,6 @@ def test_validation_eye_catch_url_max(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -763,7 +752,6 @@ def test_validation_eye_catch_url_format(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -793,7 +781,6 @@ def test_validation_paid_article_publish_ok(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -855,7 +842,6 @@ def test_validation_paid_article_publish_without_paid_body_ng(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -887,7 +873,6 @@ def test_validation_paid_article_publish_without_price_ng(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } @@ -920,7 +905,6 @@ def test_make_article_free_ok(self): 'authorizer': { 'claims': { 'cognito:username': 'test01', - 'custom:private_eth_address': '0x1234567890123456789012345678901234567890', 'phone_number_verified': 'true', 'email_verified': 'true' } From ebb11c59142da6c8fc44989c5c7621be8a0ef37e Mon Sep 17 00:00:00 2001 From: sot528 Date: Mon, 27 Apr 2020 18:54:06 +0900 Subject: [PATCH 8/8] fix --- .../me_articles_drafts_publish_with_header.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers/me/articles/drafts/publish_with_header/me_articles_drafts_publish_with_header.py b/src/handlers/me/articles/drafts/publish_with_header/me_articles_drafts_publish_with_header.py index 5bf00d68..2410e182 100644 --- a/src/handlers/me/articles/drafts/publish_with_header/me_articles_drafts_publish_with_header.py +++ b/src/handlers/me/articles/drafts/publish_with_header/me_articles_drafts_publish_with_header.py @@ -34,8 +34,8 @@ def get_schema(self): def validate_params(self): UserUtil.verified_phone_and_email(self.event) - if self.event['requestContext']['authorizer']['claims'].get('custom:private_eth_address') is None: - raise ValidationError('not exists private_eth_address') + UserUtil.validate_private_eth_address(self.dynamodb, + self.event['requestContext']['authorizer']['claims']['cognito:username']) # check price type is integer or decimal ParameterUtil.validate_price_params(self.params.get('price'))