Skip to content

Commit

Permalink
refactor(model): update PaymentProcessor model and migration
Browse files Browse the repository at this point in the history
remove Customer-API-related fields and add new Backoffice API fields
  • Loading branch information
angela-tran committed Mar 7, 2024
1 parent 6c6bb80 commit ed26642
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 5.0.2 on 2024-02-28 23:18

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("core", "0002_paymentprocessor_audience_paymentprocessor_client_id_and_more"),
]

operations = [
migrations.RemoveField(
model_name="paymentprocessor",
name="api_access_token_endpoint",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="api_access_token_request_key",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="api_access_token_request_val",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="client_cert",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="client_cert_private_key",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="client_cert_root_ca",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="customer_endpoint",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="customers_endpoint",
),
migrations.RemoveField(
model_name="paymentprocessor",
name="group_endpoint",
),
]
123 changes: 12 additions & 111 deletions benefits/core/migrations/local_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,87 +35,6 @@
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 5,
"fields": {
"label": "(MST) payment processor client certificate",
"text_secret_name": "mst-payment-processor-client-cert",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 6,
"fields": {
"label": "(MST) payment processor client certificate private key",
"text_secret_name": "mst-payment-processor-client-cert-private-key",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 7,
"fields": {
"label": "(MST) payment processor client certificate root CA",
"text_secret_name": "mst-payment-processor-client-cert-root-ca",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 8,
"fields": {
"label": "(SacRT) payment processor client certificate",
"text_secret_name": "sacrt-payment-processor-client-cert",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 9,
"fields": {
"label": "(SacRT) payment processor client certificate private key",
"text_secret_name": "sacrt-payment-processor-client-cert-private-key",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 10,
"fields": {
"label": "(SacRT) payment processor client certificate root CA",
"text_secret_name": "sacrt-payment-processor-client-cert-root-ca",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 11,
"fields": {
"label": "(SBMTD) payment processor client certificate",
"text_secret_name": "sbmtd-payment-processor-client-cert",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 12,
"fields": {
"label": "(SBMTD) payment processor client certificate private key",
"text_secret_name": "sbmtd-payment-processor-client-cert-private-key",
"remote_url": null
}
},
{
"model": "core.pemdata",
"pk": 13,
"fields": {
"label": "(SBMTD) payment processor client certificate root CA",
"text_secret_name": "sbmtd-payment-processor-client-cert-root-ca",
"remote_url": null
}
},
{
"model": "core.authprovider",
"pk": 1,
Expand Down Expand Up @@ -324,18 +243,12 @@
"fields": {
"name": "(MST) test payment processor",
"api_base_url": "http://server:8000",
"api_access_token_endpoint": "access-token",
"api_access_token_request_key": "request_access",
"api_access_token_request_val": "REQUEST_ACCESS",
"client_id": "",
"client_secret_name": "",
"audience": "",
"card_tokenize_url": "http://server:8000/static/tokenize.js",
"card_tokenize_func": "tokenize",
"card_tokenize_env": "test",
"client_cert": 5,
"client_cert_private_key": 6,
"client_cert_root_ca": 7,
"customer_endpoint": "customer",
"customers_endpoint": "customers",
"group_endpoint": "group"
"card_tokenize_env": "test"
}
},
{
Expand All @@ -344,18 +257,12 @@
"fields": {
"name": "(SacRT) test payment processor",
"api_base_url": "http://server:8000",
"api_access_token_endpoint": "access-token",
"api_access_token_request_key": "request_access",
"api_access_token_request_val": "REQUEST_ACCESS",
"client_id": "",
"client_secret_name": "",
"audience": "",
"card_tokenize_url": "http://server:8000/static/tokenize.js",
"card_tokenize_func": "tokenize",
"card_tokenize_env": "test",
"client_cert": 8,
"client_cert_private_key": 9,
"client_cert_root_ca": 10,
"customer_endpoint": "customer",
"customers_endpoint": "customers",
"group_endpoint": "group"
"card_tokenize_env": "test"
}
},
{
Expand All @@ -364,18 +271,12 @@
"fields": {
"name": "(SBMTD) test payment processor",
"api_base_url": "http://server:8000",
"api_access_token_endpoint": "access-token",
"api_access_token_request_key": "request_access",
"api_access_token_request_val": "REQUEST_ACCESS",
"client_id": "",
"client_secret_name": "",
"audience": "",
"card_tokenize_url": "http://server:8000/static/tokenize.js",
"card_tokenize_func": "tokenize",
"card_tokenize_env": "test",
"client_cert": 11,
"client_cert_private_key": 12,
"client_cert_root_ca": 13,
"customer_endpoint": "customer",
"customers_endpoint": "customers",
"group_endpoint": "group"
"card_tokenize_env": "test"
}
},
{
Expand Down
12 changes: 0 additions & 12 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,12 @@ class PaymentProcessor(models.Model):
id = models.AutoField(primary_key=True)
name = models.TextField()
api_base_url = models.TextField()
api_access_token_endpoint = models.TextField()
api_access_token_request_key = models.TextField()
api_access_token_request_val = models.TextField()
client_id = models.TextField()
client_secret_name = SecretNameField()
audience = models.TextField()
card_tokenize_url = models.TextField()
card_tokenize_func = models.TextField()
card_tokenize_env = models.TextField()
# The certificate used for client certificate authentication to the API
client_cert = models.ForeignKey(PemData, related_name="+", on_delete=models.PROTECT)
# The private key, used to sign the certificate
client_cert_private_key = models.ForeignKey(PemData, related_name="+", on_delete=models.PROTECT)
# The root CA bundle, used to verify the server.
client_cert_root_ca = models.ForeignKey(PemData, related_name="+", on_delete=models.PROTECT)
customer_endpoint = models.TextField()
customers_endpoint = models.TextField()
group_endpoint = models.TextField()

@property
def client_secret(self):
Expand Down
11 changes: 1 addition & 10 deletions tests/pytest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,16 @@ def model_EligibilityVerifier_AuthProvider_with_verification(model_AuthProvider_


@pytest.fixture
def model_PaymentProcessor(model_PemData):
def model_PaymentProcessor():
payment_processor = PaymentProcessor.objects.create(
name="Test Payment Processor",
api_base_url="https://example.com/payments",
api_access_token_endpoint="token",
api_access_token_request_key="X-API-TOKEN",
api_access_token_request_val="secret-value",
client_id="client_id",
client_secret_name="client_secret_name",
audience="audience",
card_tokenize_url="https://example.com/payments/tokenize.js",
card_tokenize_func="tokenize",
card_tokenize_env="test",
client_cert=model_PemData,
client_cert_private_key=model_PemData,
client_cert_root_ca=model_PemData,
customer_endpoint="customer",
customers_endpoint="customers",
group_endpoint="group",
)

return payment_processor
Expand Down

0 comments on commit ed26642

Please sign in to comment.