Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Added staticfile option for provision #203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions wolf/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class Wolf(Application):
iso8583:
mackey: 1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C
pinkey: 1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C
provision:
delivery: maskansmsprovider
filename: %(data_dir)s/provision-strings.csv

'''

Expand Down
13 changes: 13 additions & 0 deletions wolf/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
def create_soap_client(wsdl):
return zeep.Client(wsdl)

def deliver_provisioning(phone, provisionstring):
config = settings.iso8583.provision

if config.delivery == 'staticfile':
with open(config.filename, 'a') as codes_file:
codes_file.write(f'{phone}, {provisionstring}\n')

elif config.delivery == 'maskansmsprovider':
sms_response = MaskanSmsProvider().send(
phone,
provisionstring[:120]
)


class MaskanSmsProvider:
def __init__(self):
Expand Down
7 changes: 2 additions & 5 deletions wolf/iso8583.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .models import Token, MiniToken, Cryptomodule, Person
from wolf.authentication import MaskanAuthenticator
from wolf.backends import MaskanClient
from wolf.helpers import MaskanSmsProvider
from wolf.helpers import MaskanSmsProvider, deliver_provisioning


logger = get_logger('ISO8583')
Expand Down Expand Up @@ -342,10 +342,7 @@ def zero_padding_datetime(value):

try:
provision = token.provision(f'98{phone[-10:]}').split('/')[-1]
sms_response = MaskanSmsProvider().send(
phone,
provision[:120]
)
sms_response = deliver_provisioning(phone, provision)

except HTTPKnownStatus:
logger.exception(traceback.format_exc())
Expand Down