Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinan029 committed Dec 2, 2024
2 parents d6b0e9b + 12f3e25 commit d3e1a16
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 134 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [master]
pull_request:
branches: [master]

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ Unreleased
----------
* nothing unreleased

[4.33.2]
[5.1.0]
--------
* feat: update EnterpriseGroupMembershipSerializer to include learner course enrollment count
* feat: updated learner query to filter by full name

[5.0.0]
--------
* refactor: Removed `plotly_token/` API endpoint and related views from enterprise API.

[4.33.1]
--------
* feat: Creating enterprise customer members endpoint for admin portal
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.33.2"
__version__ = "5.1.0"
6 changes: 0 additions & 6 deletions enterprise/api/v1/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
notifications,
pending_enterprise_customer_admin_user,
pending_enterprise_customer_user,
plotly_auth,
)

router = DefaultRouter()
Expand Down Expand Up @@ -131,11 +130,6 @@
coupon_codes.CouponCodesView.as_view(),
name='request-codes'
),
re_path(
r'^plotly_token/(?P<enterprise_uuid>[A-Za-z0-9-]+)$',
plotly_auth.PlotlyAuthView.as_view(),
name='plotly-token'
),
re_path(
r'^enterprise_report_types/(?P<enterprise_uuid>[A-Za-z0-9-]+)$',
enterprise_customer_reporting.EnterpriseCustomerReportTypesView.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion enterprise/api/v1/views/enterprise_customer_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_members(self, request, *args, **kwargs):
au.id,
au.email,
au.date_joined,
coalesce(NULLIF(aup.name, ' '), (au.first_name || ' ' || au.last_name)) as full_name
coalesce(NULLIF(aup.name, ''), (au.first_name || ' ' || au.last_name)) as full_name
FROM enterprise_enterprisecustomeruser ecu
INNER JOIN auth_user as au on ecu.user_id = au.id
LEFT JOIN auth_userprofile as aup on au.id = aup.user_id
Expand Down
62 changes: 0 additions & 62 deletions enterprise/api/v1/views/plotly_auth.py

This file was deleted.

62 changes: 0 additions & 62 deletions tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from urllib.parse import parse_qs, urlencode, urljoin, urlsplit, urlunsplit

import ddt
import jwt
import pytz
import responses
from edx_toggles.toggles.testutils import override_waffle_flag
Expand Down Expand Up @@ -7755,67 +7754,6 @@ def test_same_enable_universal_link(self):
self.assertEqual(response['detail'], 'No changes')


@mark.django_db
class TestPlotlyAuthView(APITest):
"""
Test PlotlyAuthView
"""

PLOTLY_TOKEN_ENDPOINT = 'plotly-token'

def setUp(self):
"""
Common setup for all tests.
"""
super().setUp()
self.client.login(username=self.user.username, password=TEST_PASSWORD)
self.enterprise_uuid = fake.uuid4()
self.enterprise_uuid2 = fake.uuid4()
self.url = settings.TEST_SERVER + reverse(
self.PLOTLY_TOKEN_ENDPOINT, kwargs={'enterprise_uuid': self.enterprise_uuid}
)

def test_view_with_normal_user(self):
"""
Verify that a user without having `enterprise.can_access_admin_dashboard` role can't access the view.
"""
response = self.client.get(self.url)
assert response.status_code == status.HTTP_403_FORBIDDEN
assert response.json() == {'detail': 'Missing: enterprise.can_access_admin_dashboard'}

def test_view_with_admin_user(self):
"""
Verify that an enterprise admin user having `enterprise.can_access_admin_dashboard` role can access the view.
"""
EnterpriseCustomerFactory.create(uuid=self.enterprise_uuid, enable_audit_data_reporting=True)
self.set_jwt_cookie(ENTERPRISE_ADMIN_ROLE, self.enterprise_uuid)

self.client.login(username=self.user.username, password=TEST_PASSWORD)

response = self.client.get(self.url)
assert response.status_code == status.HTTP_200_OK
assert 'token' in response.json()
token = response.json().get('token')
decoded_jwt = jwt.decode(token, settings.ENTERPRISE_PLOTLY_SECRET, algorithms=['HS512'])
assert decoded_jwt['audit_data_reporting_enabled'] is True

def test_view_with_admin_user_tries(self):
"""
Verify that an enterprise admin can create token for enterprise uuid present in jwt roles only.
"""
self.set_jwt_cookie(ENTERPRISE_ADMIN_ROLE, self.enterprise_uuid)

url = settings.TEST_SERVER + reverse(
self.PLOTLY_TOKEN_ENDPOINT, kwargs={'enterprise_uuid': self.enterprise_uuid2}
)

self.client.login(username=self.user.username, password=TEST_PASSWORD)

response = self.client.get(url)
assert response.status_code == status.HTTP_403_FORBIDDEN
assert response.json() == {'detail': 'Missing: enterprise.can_access_admin_dashboard'}


@mark.django_db
class TestAnalyticsSummaryView(APITest):
"""
Expand Down

0 comments on commit d3e1a16

Please sign in to comment.