Skip to content

Commit

Permalink
Removed blackboard unencrypted columns from models ent8010 (#2096)
Browse files Browse the repository at this point in the history
feat: removed client_id and client_secret from db models
  • Loading branch information
MueezKhan246 authored May 28, 2024
1 parent fbf09cd commit dfe0661
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 57 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ Unreleased
----------
* nothing unreleased

[4.18.4]
[4.19.5]
--------
* feat: removed unencrypted columns of user data credentials in blackboard config ENT 8010

[4.19.4]
--------
* feat: removed unencrypted columns of user data credentials in blackboard config ENT 8010

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.19.4"
__version__ = "4.19.5"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.23 on 2024-05-07 10:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blackboard', '0021_auto_20240423_1057'),
]

operations = [
migrations.RemoveField(
model_name='blackboardenterprisecustomerconfiguration',
name='client_id',
),
migrations.RemoveField(
model_name='blackboardenterprisecustomerconfiguration',
name='client_secret',
),
]
22 changes: 0 additions & 22 deletions integrated_channels/blackboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ class BlackboardEnterpriseCustomerConfiguration(EnterpriseCustomerPluginConfigur
The Enterprise-specific configuration we need for integrating with Blackboard.
"""

client_id = models.CharField(
max_length=255,
blank=True,
default='',
verbose_name="API Client ID or Blackboard Application Key",
help_text=(
"The API Client ID provided to edX by the enterprise customer to be used to make API "
"calls on behalf of the customer. Called Application Key in Blackboard"
)
)

decrypted_client_id = EncryptedCharField(
max_length=255,
blank=True,
Expand Down Expand Up @@ -143,17 +132,6 @@ def encrypted_client_id(self, value):
"""
self.decrypted_client_id = value

client_secret = models.CharField(
max_length=255,
blank=True,
default='',
verbose_name="API Client Secret or Application Secret",
help_text=(
"The API Client Secret provided to edX by the enterprise customer to be used to make "
" API calls on behalf of the customer. Called Application Secret in Blackboard"
)
)

decrypted_client_secret = EncryptedCharField(
max_length=255,
blank=True,
Expand Down
4 changes: 2 additions & 2 deletions integrated_channels/blackboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ def _create_auth_header(self, enterprise_config, blackboard_global_config):
"""
Auth header in oauth2 token format as per Blackboard doc
"""
app_key = enterprise_config.client_id
app_key = enterprise_config.decrypted_client_id
if not app_key:
if not blackboard_global_config.app_key:
raise NotFound(
"Failed to generate oauth access token: Client ID required.",
HTTPStatus.INTERNAL_SERVER_ERROR.value
)
app_key = blackboard_global_config.app_key
app_secret = enterprise_config.client_secret
app_secret = enterprise_config.decrypted_client_secret
if not app_secret:
if not blackboard_global_config.app_secret:
raise NotFound(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,8 +1706,8 @@ class TestEnterpriseCustomerViewSet(BaseTestEnterpriseAPIViews):
'enterprise_customer_id': FAKE_UUIDS[0],
'enterprise_customer__uuid': FAKE_UUIDS[0],
'blackboard_base_url': 'foobar',
'client_id': 'client_id',
'client_secret': 'client_secret',
'decrypted_client_id': 'client_id',
'decrypted_client_secret': 'client_secret',
'refresh_token': 'token',
'active': True,
'enterprise_customer__name': 'Test Enterprise Customer',
Expand Down
12 changes: 6 additions & 6 deletions tests/test_integrated_channels/test_blackboard/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def setUp(self):
self.token = 'token'
self.global_config = BlackboardGlobalConfigurationFactory()
self.enterprise_config = BlackboardEnterpriseCustomerConfigurationFactory(
client_id='id',
client_secret='secret',
decrypted_client_id='id',
decrypted_client_secret='secret',
blackboard_base_url='https://base.url',
refresh_token=self.token,
)
Expand Down Expand Up @@ -78,8 +78,8 @@ def test_client_pulls_auth_creds_from_global_if_not_found(self):

def test_oauth_absent_refresh_token_fails(self):
enterprise_config = BlackboardEnterpriseCustomerConfigurationFactory(
client_id='id2',
client_secret='secret',
decrypted_client_id='id2',
decrypted_client_secret='secret',
blackboard_base_url='https://base.url.2',
refresh_token='',
)
Expand All @@ -94,8 +94,8 @@ def test_oauth_valid_refresh_token_replaces_existing(self):
a valid refresh_token is used to replace it, and access_token is obtained
"""
enterprise_config = BlackboardEnterpriseCustomerConfigurationFactory(
client_id='id3',
client_secret='secret',
decrypted_client_id='id3',
decrypted_client_secret='secret',
blackboard_base_url='https://base.url.3',
refresh_token='a-token',
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def setUp(self):
self.config = factories.BlackboardEnterpriseCustomerConfigurationFactory(
enterprise_customer=self.enterprise_customer,
blackboard_base_url='foobar',
client_id='client_id',
client_secret='client_secret',
decrypted_client_id='client_id',
decrypted_client_secret='client_secret',
refresh_token='token',
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def setUp(self):
self.enterprise_config = factories.BlackboardEnterpriseCustomerConfigurationFactory(
enterprise_customer=self.enterprise_customer,
blackboard_base_url='foobar',
client_id='client_id',
client_secret='client_secret',
decrypted_client_id='client_id',
decrypted_client_secret='client_secret',
refresh_token='token',
)
self.completion_payload = BlackboardLearnerDataTransmissionAudit(
Expand Down
55 changes: 36 additions & 19 deletions tests/test_integrated_channels/test_blackboard/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,42 @@ def setUp(self):
self.refresh_token = 'test-refresh-token'
self.urlbase = reverse('blackboard-oauth-complete')

BlackboardEnterpriseCustomerConfiguration.objects.get_or_create(
uuid=SINGLE_CONFIG['uuid'],
client_id=SINGLE_CONFIG['client_id'],
client_secret=SINGLE_CONFIG['client_secret'],
blackboard_base_url=SINGLE_CONFIG['base_url'],
enterprise_customer=self.enterprise_customer,
active=True,
enterprise_customer_id=ENTERPRISE_ID,
)

BlackboardEnterpriseCustomerConfiguration.objects.get_or_create(
uuid=SECOND_CONFIG['uuid'],
client_id=SECOND_CONFIG['client_id'],
client_secret=SECOND_CONFIG['client_secret'],
blackboard_base_url=SECOND_CONFIG['base_url'],
enterprise_customer=self.enterprise_customer,
active=True,
enterprise_customer_id=ENTERPRISE_ID,
)
try:
BlackboardEnterpriseCustomerConfiguration.objects.get(
uuid=SINGLE_CONFIG['uuid'],
blackboard_base_url=SINGLE_CONFIG['base_url'],
enterprise_customer=self.enterprise_customer,
active=True,
enterprise_customer_id=ENTERPRISE_ID,
)
except BlackboardEnterpriseCustomerConfiguration.DoesNotExist:
BlackboardEnterpriseCustomerConfiguration.objects.create(
uuid=SINGLE_CONFIG['uuid'],
decrypted_client_id=SINGLE_CONFIG['client_id'],
decrypted_client_secret=SINGLE_CONFIG['client_secret'],
blackboard_base_url=SINGLE_CONFIG['base_url'],
enterprise_customer=self.enterprise_customer,
active=True,
enterprise_customer_id=ENTERPRISE_ID,
)
try:
BlackboardEnterpriseCustomerConfiguration.objects.get(
uuid=SECOND_CONFIG['uuid'],
blackboard_base_url=SECOND_CONFIG['base_url'],
enterprise_customer=self.enterprise_customer,
active=True,
enterprise_customer_id=ENTERPRISE_ID,
)
except BlackboardEnterpriseCustomerConfiguration.DoesNotExist:
BlackboardEnterpriseCustomerConfiguration.objects.create(
uuid=SECOND_CONFIG['uuid'],
decrypted_client_id=SECOND_CONFIG['client_id'],
decrypted_client_secret=SECOND_CONFIG['client_secret'],
blackboard_base_url=SECOND_CONFIG['base_url'],
enterprise_customer=self.enterprise_customer,
active=True,
enterprise_customer_id=ENTERPRISE_ID,
)

def test_successful_refresh_token_by_uuid_request(self):
"""
Expand Down

0 comments on commit dfe0661

Please sign in to comment.