Skip to content

Commit

Permalink
Merge pull request #9 from rtrdev/master
Browse files Browse the repository at this point in the history
Reordered Server authentication
  • Loading branch information
theduderog committed Nov 7, 2015
2 parents 44fe0da + 5994fa7 commit 887e164
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions smpp/twisted/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,16 @@ def doBindRequest(self, reqPDU, sessionState):
try:
iface, auth_avatar, logout = yield self.factory.login(system_id, password, self.transport.getPeer().host)
except error.UnauthorizedLogin:
if system_id not in self.factory.config.systems.keys():
self.log.warning('SMPP Bind request failed for system_id: "%s", System ID not configured' % system_id)
self.sendErrorResponse(reqPDU, CommandStatus.ESME_RINVSYSID, system_id)
else:
self.log.warning('SMPP Bind request failed for system_id: "%s", failed to authenticate' % system_id)
self.sendErrorResponse(reqPDU, CommandStatus.ESME_RINVPASWD, system_id)
self.log.warning('SMPP Bind request failed for system_id: "%s", failed to authenticate' % system_id)
self.sendErrorResponse(reqPDU, CommandStatus.ESME_RINVPASWD, system_id)
return

# Only a configured system_id can bind
if system_id not in self.factory.config.systems.keys():
self.log.warning('SMPP Bind request failed for system_id: "%s", System ID not configured' % system_id)
self.sendErrorResponse(reqPDU, CommandStatus.ESME_RINVSYSID, system_id)
return

# Check we're not already bound, and are open to being bound
if self.sessionState != SMPPSessionStates.OPEN:
self.log.warning('Duplicate SMPP bind request received from: %s' % system_id)
Expand Down
2 changes: 1 addition & 1 deletion smpp/twisted/tests/test_smpp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def testTRXBindRequestInvalidSysId(self):
seqNum = 1
)
self.proto.dataReceived(self.encoder.encode(pdu))
expected_pdu = operations.BindTransceiverResp(system_id='userB', seqNum=1, status=pdu_types.CommandStatus.ESME_RINVSYSID)
expected_pdu = operations.BindTransceiverResp(system_id='userB', seqNum=1, status=pdu_types.CommandStatus.ESME_RINVPASWD)
self.assertEqual(self.tr.value(), self.encoder.encode(expected_pdu))
connection = self.factory.getBoundConnections('userA')
self.assertEqual(connection, None)
Expand Down

0 comments on commit 887e164

Please sign in to comment.