-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update EnterpriseGroupMembershipSerializer to include enrollmen…
…t count (#2286) * feat: update EnterpriseGroupMembershipSerializer to include learner course enrollment count and updated query to filter by name
- Loading branch information
1 parent
12f3e25
commit 0b70eea
Showing
6 changed files
with
32 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
Your project description goes here. | ||
""" | ||
|
||
__version__ = "5.0.0" | ||
__version__ = "5.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8341,65 +8341,6 @@ def test_list_learners_bad_sort_by(self): | |
assert response.status_code == 400 | ||
assert response.data.get('user_query') | ||
|
||
def test_list_learners_filtered(self): | ||
""" | ||
Test that the list learners endpoint can be filtered by user details | ||
""" | ||
group = EnterpriseGroupFactory( | ||
enterprise_customer=self.enterprise_customer, | ||
) | ||
pending_user = PendingEnterpriseCustomerUserFactory( | ||
user_email="[email protected]", | ||
enterprise_customer=self.enterprise_customer, | ||
) | ||
pending_user_query_string = f'?user_query={pending_user.user_email}' | ||
url = settings.TEST_SERVER + reverse( | ||
'enterprise-group-learners', | ||
kwargs={'group_uuid': group.uuid}, | ||
) + pending_user_query_string | ||
response = self.client.get(url) | ||
|
||
assert response.json().get('count') == 0 | ||
|
||
group.save() | ||
pending_membership = EnterpriseGroupMembershipFactory( | ||
group=group, | ||
pending_enterprise_customer_user=pending_user, | ||
enterprise_customer_user=None, | ||
) | ||
existing_membership = EnterpriseGroupMembershipFactory( | ||
group=group, | ||
pending_enterprise_customer_user=None, | ||
enterprise_customer_user__enterprise_customer=self.enterprise_customer, | ||
) | ||
existing_user = existing_membership.enterprise_customer_user.user | ||
# Changing email to something that we know will be unique for collision purposes | ||
existing_user.email = "[email protected]" | ||
existing_user.save() | ||
existing_user_query_string = '?user_query=ayylmao' | ||
url = settings.TEST_SERVER + reverse( | ||
'enterprise-group-learners', | ||
kwargs={'group_uuid': group.uuid}, | ||
) + existing_user_query_string | ||
response = self.client.get(url) | ||
|
||
assert response.json().get('count') == 1 | ||
assert response.json().get('results')[0].get( | ||
'enterprise_customer_user_id' | ||
) == existing_membership.enterprise_customer_user.id | ||
|
||
url = settings.TEST_SERVER + reverse( | ||
'enterprise-group-learners', | ||
kwargs={'group_uuid': group.uuid}, | ||
) + pending_user_query_string | ||
|
||
response = self.client.get(url) | ||
|
||
assert response.json().get('count') == 1 | ||
assert response.json().get('results')[0].get( | ||
'pending_enterprise_customer_user_id' | ||
) == pending_membership.pending_enterprise_customer_user.id | ||
|
||
def test_list_removed_learners(self): | ||
group = EnterpriseGroupFactory( | ||
enterprise_customer=self.enterprise_customer, | ||
|
@@ -8500,6 +8441,7 @@ def test_successful_list_learners(self): | |
}, | ||
'recent_action': f'Accepted: {datetime.now().strftime("%B %d, %Y")}', | ||
'status': 'pending', | ||
'enrollments': 0, | ||
}, | ||
) | ||
expected_response = { | ||
|
@@ -8541,6 +8483,7 @@ def test_successful_list_learners(self): | |
}, | ||
'recent_action': f'Accepted: {datetime.now().strftime("%B %d, %Y")}', | ||
'status': 'pending', | ||
'enrollments': 0, | ||
} | ||
], | ||
} | ||
|
@@ -8632,23 +8575,6 @@ def test_successful_list_with_filters(self): | |
assert len(enterprise_filtered_response.json().get('results')) == 1 | ||
assert learner_filtered_response.json().get('results')[0].get('uuid') == str(new_group.uuid) | ||
|
||
def test_list_members_little_bobby_tables(self): | ||
""" | ||
Test that we properly sanitize member user query filters | ||
https://xkcd.com/327/ | ||
""" | ||
# url: 'http://testserver/enterprise/api/v1/enterprise_group/<group uuid>/learners/' | ||
url = settings.TEST_SERVER + reverse( | ||
'enterprise-group-learners', | ||
kwargs={'group_uuid': self.group_1.uuid}, | ||
) | ||
# The problematic child | ||
filter_query_param = "?user_query=Robert`); DROP TABLE enterprise_enterprisecustomeruser;--" | ||
sql_injection_protected_response = self.client.get(url + filter_query_param) | ||
assert sql_injection_protected_response.status_code == 200 | ||
assert not sql_injection_protected_response.json().get('results') | ||
assert EnterpriseCustomerUser.objects.all() | ||
|
||
def test_successful_post_group(self): | ||
""" | ||
Test creating a new group record | ||
|