Skip to content

Commit

Permalink
Merge pull request #949 from jookies/0.10
Browse files Browse the repository at this point in the history
0.10.8
  • Loading branch information
farirat committed Jan 24, 2021
2 parents 350a915 + 8e36dc9 commit d7de31d
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 90 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ python:
- '3.6'
- '3.7'
- '3.8'
# - '3.9'
- '3.9'
env:
- ROOT_PATH=~/jasmin JASMIN_RELEASE=0.10.6
- ROOT_PATH=~/jasmin JASMIN_RELEASE=0.10.8
# Command to install dependencies
install:
- pip install -r requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion jasmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

MAJOR = 0
MINOR = 10
PATCH = 6
PATCH = 8
META = ''


Expand Down
4 changes: 2 additions & 2 deletions jasmin/protocols/smpp/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def isDeliveryReceipt(self, pdu):
# Look for patterns and compose return object
for pattern in patterns:
if isinstance(pdu.params['short_message'], bytes):
m = re.search(pattern, pdu.params['short_message'].decode())
m = re.search(pattern, pdu.params['short_message'].decode('utf-8', 'ignore'))
else:
m = re.search(pattern, pdu.params['short_message'])
if m:
Expand Down Expand Up @@ -307,4 +307,4 @@ def getReceipt(self, dlr_pdu, msgid, source_addr, destination_addr, message_stat
def get_enum(self, enum_type, value):
if isinstance(value, Enum):
return value
return getattr(enum_type, value.lstrip(str(enum_type) + '.'))
return getattr(enum_type, value.lstrip(str(enum_type) + '.'))
12 changes: 8 additions & 4 deletions jasmin/routing/Filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def __init__(self, source_addr):
def match(self, routable):
Filter.match(self, routable)

return False if self.source_addr.match(routable.pdu.params['source_addr']) is None else True
return False if self.source_addr.match(
routable.pdu.params['source_addr'].decode('utf-8', 'replace')) is None else True


class DestinationAddrFilter(Filter):
Expand All @@ -184,7 +185,8 @@ def __init__(self, destination_addr):
def match(self, routable):
Filter.match(self, routable)

if self.destination_addr.match(routable.pdu.params['destination_addr']) is None:
if self.destination_addr.match(
routable.pdu.params['destination_addr'].decode('utf-8', 'replace')) is None:
return False
else:
return True
Expand All @@ -202,9 +204,11 @@ def match(self, routable):

# Content can be short_message or message_payload:
if 'short_message' in routable.pdu.params:
return False if self.short_message.match(routable.pdu.params['short_message']) is None else True
return False if self.short_message.match(
routable.pdu.params['short_message'].decode('utf-8', 'replace')) is None else True
elif 'message_payload' in routable.pdu.params:
return False if self.short_message.match(routable.pdu.params['message_payload']) is None else True
return False if self.short_message.match(
routable.pdu.params['message_payload'].decode('utf-8', 'replace')) is None else True
else:
return False

Expand Down
2 changes: 1 addition & 1 deletion misc/doc/sources/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# The short X.Y version.
version = "0.10"
# The full version, including alpha/beta/rc tags.
release = "0.10.6"
release = "0.10.8"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
27 changes: 27 additions & 0 deletions misc/doc/sources/installation/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3"

services:
redis:
image: redis:alpine
restart: unless-stopped

rabbit-mq:
image: rabbitmq:alpine
restart: unless-stopped

jasmin:
image: jookies/jasmin:0.10
restart: unless-stopped
container_name: jasmin
volumes:
- /var/log/jasmin:/var/log/jasmin
ports:
- 2775:2775
- 8990:8990
- 1401:1401
depends_on:
- redis
- rabbit-mq
environment:
REDIS_CLIENT_HOST: redis
AMQP_BROKER_HOST: rabbit-mq
51 changes: 16 additions & 35 deletions misc/doc/sources/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,55 +119,36 @@ Installing Docker

Before we get into containers, we'll need to get Docker running locally. You can do this by installing the
package for your system (tip: you can find `yours here <https://docs.docker.com/installation/#installation>`_).
Running a Mac? You'll need to install the `boot2docker application <http://boot2docker.io/>`_ before using Docker.

Once that's set up, you're ready to start using Jasmin container !

Pulling Jasmin image
Using docker-compose
====================

This command will pull latest jasmin docker image to your computer::
Create a file named "docker-compose.yml" and paste the following:

.. literalinclude:: /installation/docker-compose.yml
:language: yaml

Then spin it::

docker pull jookies/jasmin
docker-compose up -d

You should have Jasmin image listed in your local docker images::
This command will pull latest jasmin v0.10, latest redis and latest rabbitmq images to your computer::

# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
jasmin latest 0e4cf8879899 36 minutes ago 478.6 MB

.. note:: The Jasmin docker image is a self-contained/standalone box including Jasmin+Redis+RabbitMQ.

Starting Jasmin in a container
==============================

This command will create a new docker container with name *jasmin_01* which run as a demon::

docker run -d -p 1401:1401 -p 2775:2775 -p 8990:8990 --name jasmin_01 jookies/jasmin:latest

Note that we used the parameter **-p** three times, it defines port forwarding from host computer to the container,
typing **-p 2775:2775** will map the container's 2775 port to your host 2775 port; this can
be useful in case you'll be running multiple containers of Jasmin where you keep a port offset of 10 between
each, example::

docker run -d -p 1411:1401 -p 2785:2775 -p 8990:8990 --name jasmin_02 jookies/jasmin:latest
docker run -d -p 1421:1401 -p 2795:2775 -p 9000:8990 --name jasmin_03 jookies/jasmin:latest
docker run -d -p 1431:1401 -p 2805:2775 -p 9010:8990 --name jasmin_04 jookies/jasmin:latest

You should have the container running by typing the following::
Jasmin is now up and running::

# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a2fafbe60d0 jookies/jasmin:latest "/docker-entrypoint. 43 minutes ago Up 41 minutes 0.0.0.0:1401->1401/tcp, 0.0.0.0:2775->2775/tcp, 0.0.0.0:8990->8990/tcp jasmin_01

And in order to control the container **jasmin_01**, use::

docker stop jasmin_01
docker start jasmin_01

It's possible to access log files located in **/var/log/jasmin** inside the container by mounting it as a shared
folder::
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1a9016d298bf jookies/jasmin:0.10 "/docker-entrypoint.…" 3 seconds ago Up 2 seconds 0.0.0.0:1401->1401/tcp, 0.0.0.0:2775->2775/tcp, 0.0.0.0:8990->8990/tcp jasmin
af450de4fb95 rabbitmq:alpine "docker-entrypoint.s…" 5 seconds ago Up 3 seconds 4369/tcp, 5671-5672/tcp, 15691-15692/tcp, 25672/tcp rabbitmq
c8feb6c07d94 redis:alpine "docker-entrypoint.s…" 5 seconds ago Up 3 seconds 6379/tcp redis

docker run -d -v /home/user/jasmin_logs:/var/log/jasmin --name jasmin_100 jookies/jasmin:latest
.. note:: You can play around with the docker-compose.yml to choose different versions, mounting the configs outside the container, etc ...

Sending your first SMS
**********************
Expand Down
2 changes: 1 addition & 1 deletion nfpm.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "jasmin-sms-gateway"
arch: "amd64"
platform: "linux"
version: "v0.10.6"
version: "v0.10.8"
section: "default"
priority: "extra"
maintainer: "Jookies LTD <jasmin@jookies.net>"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ txredisapi~=1.4.7
tabulate~=0.8.7

txAMQP3~=0.9.0
smpp.pdu3~=0.4
smpp.pdu3~=0.6
smpp.twisted3~=0.6
python-messaging~=0.5.13

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def parse_requirements(filename):

setup(
name="jasmin",
version='0.10.6',
version='0.10.8',
author="Jookies LTD",
author_email="jasmin@jookies.net",
url="https://www.jasminsms.com",
Expand Down
26 changes: 26 additions & 0 deletions tests/protocols/smpp/test_pdu_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,32 @@ def test_unknown_command_status_34(self):
self.assertEqual(CommandId.submit_sm_resp, pdu.id)
self.assertEqual(CommandStatus.RESERVEDSTATUS_UNKNOWN_STATUS, pdu.status)

def test_deliver_sm_resp_unknown_error(self):
"""Raises a 'builtins.UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 102: ordinal not in range(128)'
ref: #937
"""
pduHex = '000000c600000005000000000000000a000201363930373137373035380005003532303030000400000000000000007a69643a30343136333432303734207375623a30303120646c7672643a303031207375626d697420646174653a3231303130343135323220646f6e6520646174653a3231303130343135323220737461743a44454c49565244206572723a30303020746578743a8441894f8820454e544f84482e208c4150414b41000e0001010006000101001e00093138643065303361000427000102'
pdu = self.getPDU(pduHex)
SMStringEncoder().decodeSM(pdu)

# Asserts
self.assertEqual(b'id:0416342074 sub:001 dlvrd:001 submit date:2101041522 done date:2101041522 stat:DELIVRD err:000 text:\x84A\x89O\x88 ENTO\x84H. \x8cAPAKA',
pdu.params['short_message'])
self.assertEqual(b'18d0e03a', pdu.params['receipted_message_id'])

def test_deliver_sm_resp_opt_param_not_allow_more_messages_to_send(self):
"""Raises a 'Optional Parameter not allowed: Invalid option more_messages_to_send'
ref: #938
"""
pduHex = '000000cb00000005000000000000000b000201363930373137373035380005003532303030000400000000000000007a69643a30343136333432303734207375623a30303120646c7672643a303031207375626d697420646174653a3231303130343135323220646f6e6520646174653a3231303130343135323220737461743a44454c49565244206572723a30303020746578743a8441894f8820454e544f84482e208c4150414b41000e0001010006000101001e000931386430653033610004270001020426000101'
pdu = self.getPDU(pduHex)
SMStringEncoder().decodeSM(pdu)

# Asserts
self.assertEqual(b'id:0416342074 sub:001 dlvrd:001 submit date:2101041522 done date:2101041522 stat:DELIVRD err:000 text:\x84A\x89O\x88 ENTO\x84H. \x8cAPAKA',
pdu.params['short_message'])
self.assertEqual(b'18d0e03a', pdu.params['receipted_message_id'])

def test_invalid_option_vendor_specific_bypass(self):
"""Related to #577"""

Expand Down
12 changes: 6 additions & 6 deletions tests/routing/test_Filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class FilterTestCase(TestCase):
def setUp(self):
self.connector = Connector('abc')
self.PDU = SubmitSM(
source_addr='20203060',
destination_addr='20203060',
short_message='hello world',
source_addr=b'20203060',
destination_addr=b'20203060',
short_message=b'hello world',
)
self.group = Group(100)
self.user = User(1, self.group, 'username', 'password')
Expand Down Expand Up @@ -83,7 +83,7 @@ class SourceAddrFilterTestCase(FilterTestCase):

def setUp(self):
FilterTestCase.setUp(self)
self.f = self._filter(b'^\d+0$')
self.f = self._filter('^\d+0$')

def test_standard(self):
self.assertTrue(self.f.match(self.routable))
Expand All @@ -98,7 +98,7 @@ class DestinationAddrFilterTestCase(FilterTestCase):

def setUp(self):
FilterTestCase.setUp(self)
self.f = self._filter(b'^20\d+')
self.f = self._filter('^20\d+')

def test_standard(self):
self.assertTrue(self.f.match(self.routable))
Expand All @@ -113,7 +113,7 @@ class ShortMessageFilterTestCase(FilterTestCase):

def setUp(self):
FilterTestCase.setUp(self)
self.f = self._filter(b'^hello.*$')
self.f = self._filter('^hello.*$')

def test_standard(self):
self.assertTrue(self.f.match(self.routable))
Expand Down
36 changes: 18 additions & 18 deletions tests/routing/test_InterceptionTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,22 @@ def setUp(self):
self.user2 = User(2, self.group100, 'username', 'password')

self.mt_filter1 = [UserFilter(self.user1)]
self.mt_filter2 = [DestinationAddrFilter(b'^10\d+')]
self.mt_filter2 = [DestinationAddrFilter('^10\d+')]
self.transparent_filter = [TransparentFilter()]
self.interceptor1 = StaticMTInterceptor(self.mt_filter1, self.script1)
self.interceptor2 = StaticMTInterceptor(self.mt_filter2, self.script2)
self.interceptor3 = StaticMTInterceptor(self.transparent_filter, self.script3)
self.interceptor4 = DefaultInterceptor(self.script4)

self.PDU_dst_1 = SubmitSM(
source_addr='x',
destination_addr='200',
short_message='hello world',
source_addr=b'x',
destination_addr=b'200',
short_message=b'hello world',
)
self.PDU_dst_2 = SubmitSM(
source_addr='x',
destination_addr='100',
short_message='hello world',
source_addr=b'x',
destination_addr=b'100',
short_message=b'hello world',
)

self.routable_matching_interceptor1 = RoutableSubmitSm(self.PDU_dst_1, self.user1)
Expand All @@ -124,28 +124,28 @@ def setUp(self):
self.script3 = MOInterceptorScript('ghi')
self.script4 = MOInterceptorScript('jkl')

self.mt_filter1 = [SourceAddrFilter(b'^10\d+')]
self.mt_filter2 = [DestinationAddrFilter(b'^90\d+')]
self.mt_filter1 = [SourceAddrFilter('^10\d+')]
self.mt_filter2 = [DestinationAddrFilter('^90\d+')]
self.transparent_filter = [TransparentFilter()]
self.interceptor1 = StaticMOInterceptor(self.mt_filter1, self.script1)
self.interceptor2 = StaticMOInterceptor(self.mt_filter2, self.script2)
self.interceptor3 = StaticMOInterceptor(self.transparent_filter, self.script3)
self.interceptor4 = DefaultInterceptor(self.script4)

self.PDU_dst_1 = DeliverSM(
source_addr='100',
destination_addr='200',
short_message='hello world',
source_addr=b'100',
destination_addr=b'200',
short_message=b'hello world',
)
self.PDU_dst_2 = DeliverSM(
source_addr='x',
destination_addr='900',
short_message='hello world',
source_addr=b'x',
destination_addr=b'900',
short_message=b'hello world',
)
self.PDU_dst_3 = DeliverSM(
source_addr='x',
destination_addr='y',
short_message='hello world',
source_addr=b'x',
destination_addr=b'y',
short_message=b'hello world',
)

self.routable_matching_interceptor1 = RoutableDeliverSm(self.PDU_dst_1, self.connector)
Expand Down

0 comments on commit d7de31d

Please sign in to comment.