Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PD Case Sensitivity #1009

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mapadroid/data_manager/modules/pogoauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def get_dependencies(self) -> List[Tuple[str, int]]:
dependencies[ind] = ('device', device_id)
return dependencies

def save(self, core_data=None, force_insert=False, ignore_issues=[], **kwargs):
self.presave_validation(ignore_issues=ignore_issues)
if self["login_type"] == "google":
self["username"] = self["username"].lower()
return super().save(force_insert=force_insert, ignore_issues=ignore_issues)

def validate_custom(self):
issues = []
if 'device_id' in self and self['device_id'] is not None:
Expand Down
13 changes: 13 additions & 0 deletions mapadroid/tests/api/test_pogoauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,16 @@ def test_device_dependency(self):
response = self.api.delete(pogoauth_obj['uri'])
self.assertEqual(response.status_code, 412)
self.remove_resources()

def test_case_sensitivity_google(self):
payload = copy.copy(APIPogoAuth.base_payload)
payload["username"] = "[email protected]"
elem, response = self.creator.create_valid_resource("pogoauth", payload=payload)
self.assertTrue(response.json()["username"] == payload["username"].lower())

def test_case_sensitivity_ptc(self):
payload = copy.copy(APIPogoAuth.base_payload)
payload["username"] = "POGOAUTH"
payload["login_type"] = "ptc"
elem, response = self.creator.create_valid_resource("pogoauth", payload=payload)
self.assertTrue(response.json()["username"] == payload["username"])
7 changes: 4 additions & 3 deletions mapadroid/tests/test_autoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from functools import wraps
import json
from typing import Any
from unittest import TestCase
import unittest
from mapadroid.tests.test_utils import get_connection_api, get_connection_mitm, ResourceCreator, GetStorage
from mapadroid.utils.walkerArgs import parse_args
from mapadroid.utils.autoconfig import AutoConfIssues
Expand Down Expand Up @@ -86,7 +86,7 @@ def decorated(self, *args, **kwargs):
return decorated


class MITMAutoConf(TestCase):
class MITMAutoConf(unittest.TestCase):
def setUp(self):
self.api = get_connection_api()
self.mitm = get_connection_mitm(self.api)
Expand Down Expand Up @@ -262,10 +262,11 @@ def test_workflow_assigned_device(self, session_id, dev_info, ss_info, api_creat
self.assertTrue(res.status_code == 200)
res = self.mitm.get('/autoconfig/{}/google'.format(session_id))
self.assertTrue(res.status_code == 200)
self.assertTrue(res.content == b'Unit\nTest')
self.assertTrue(res.content == b'unit\nTest')
res = self.mitm.delete('/autoconfig/{}/complete'.format(session_id))
self.assertTrue(res.status_code == 200)

@unittest.skip("PD emails are case sensitive")
def test_lower_case(self):
api_creator = ResourceCreator(self.api)
with GetStorage(self.api):
Expand Down
4 changes: 0 additions & 4 deletions mapadroid/utils/autoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ def validate(self, user_vals: dict) -> bool:
invalid.append((self.host_field, "Routable address from outside the server"))
except KeyError:
pass
try:
self.contents['user_id'] = self.contents['user_id'].lower()
except KeyError:
pass
issues = {}
if missing:
issues['missing'] = missing
Expand Down