[asterisk-dev] Change in testsuite[master]: Add a test for PJSIP t38 with authentication based on normal...

Jonathan Rose (Code Review) asteriskteam at digium.com
Thu Apr 2 14:44:05 CDT 2015


Jonathan Rose has uploaded a new change for review.

  https://gerrit.asterisk.org/22

Change subject: Add a test for PJSIP t38 with authentication based on normal t38 test
......................................................................

Add a test for PJSIP t38 with authentication based on normal t38 test

Change-Id: Id8fd9683dc1b61e7b1afd2b6ede857921beebb88
---
A tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
A tests/fax/pjsip/t38_with_auth/configs/ast1/pjsip.conf
A tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
A tests/fax/pjsip/t38_with_auth/configs/ast2/pjsip.conf
A tests/fax/pjsip/t38_with_auth/run-test
A tests/fax/pjsip/t38_with_auth/test-config.yaml
M tests/fax/pjsip/tests.yaml
7 files changed, 175 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/22/22/1

diff --git a/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf b/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
new file mode 100644
index 0000000..55a81b4
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[sendfax]
+exten => 1234,1,noop
+exten => 1234,n,SendFax(${ASTDATADIR}/send.tiff)
+
+exten => h,1,noop
+exten => h,n,UserEvent(FaxStatus,operation: send,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
+
diff --git a/tests/fax/pjsip/t38_with_auth/configs/ast1/pjsip.conf b/tests/fax/pjsip/t38_with_auth/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..3e34bb2
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast1/pjsip.conf
@@ -0,0 +1,30 @@
+[local-transport]
+type=transport
+protocol=udp
+bind=127.0.0.1
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+t38_udptl=yes
+context=receivefax
+media_address=127.0.0.1
+
+[ast1-t38]
+type=auth
+auth_type=userpass
+username=ast1-t38
+password=aaa
+
+[ast2-t38]
+type=auth
+auth_type=userpass
+username=ast2-t38
+password=bbb
+
+
+[ast2-t38](endpoint-template)
+from_user=ast1-t38
+auth=ast2-t38
+outbound_auth=ast1-t38
diff --git a/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf b/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
new file mode 100644
index 0000000..03f2714
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
@@ -0,0 +1,6 @@
+[receivefax]
+exten => 1234,1,noop
+exten => 1234,n,ReceiveFax(${ASTDATADIR}/receive.tiff)
+
+exten => h,1,noop
+exten => h,n,UserEvent(FaxStatus,operation: receive,status: ${FAXOPT(status)},statusstr: ${FAXOPT(statusstr)},error: ${FAXOPT(error)})
diff --git a/tests/fax/pjsip/t38_with_auth/configs/ast2/pjsip.conf b/tests/fax/pjsip/t38_with_auth/configs/ast2/pjsip.conf
new file mode 100644
index 0000000..f8f4a92
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast2/pjsip.conf
@@ -0,0 +1,29 @@
+[local-transport]
+type=transport
+protocol=udp
+bind=127.0.0.2
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+t38_udptl=yes
+context=receivefax
+media_address=127.0.0.2
+
+[ast1-t38]
+type=auth
+auth_type=userpass
+username=ast1-t38
+password=aaa
+
+[ast2-t38]
+type=auth
+auth_type=userpass
+username=ast2-t38
+password=bbb
+
+[ast1-t38](endpoint-template)
+from_user=ast2-t38
+auth=ast1-t38
+outbound_auth=ast2-t38
diff --git a/tests/fax/pjsip/t38_with_auth/run-test b/tests/fax/pjsip/t38_with_auth/run-test
new file mode 100644
index 0000000..8af0d4d
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/run-test
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2011, Digium, Inc.
+Matthew Nicholson <mnicholson at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+import os
+import re
+import shutil
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.test_case import TestCase
+
+logger = logging.getLogger(__name__)
+
+class T38Test(TestCase):
+   event_count = 0
+   success_count = 0
+
+   def __init__(self):
+      TestCase.__init__(self)
+      self.reactor_timeout = 120
+      self.create_asterisk(2)
+
+      # copy the tiff file we are going to send to a good known location
+      shutil.copy("%s/send.tiff" % (os.path.dirname(os.path.realpath(__file__)),), "%s%s" % (self.ast[0].base, self.ast[0].directories['astdatadir']))
+
+   def ami_connect(self, ami):
+      if ami.id == 0:
+
+         ami.registerEvent('UserEvent', self.fax_result)
+         df = ami.originate("PJSIP/ast2-t38/sip:1234 at 127.0.0.2", "sendfax", "1234", 1)
+
+         def handle_failure(reason):
+            logging.error("error sending originate:")
+            logging.error(reason.getTraceback())
+            self.stop_reactor()
+
+            return reason
+
+         df.addErrback(handle_failure)
+
+   def fax_result(self, ami, event):
+      if event['userevent'] != 'FaxStatus':
+         return
+
+      if event['status'] == "SUCCESS":
+         self.passed = True
+      else:
+         logging.error("error sending fax through t38:")
+         logging.error("operation: %s" % (event['operation'],))
+         logging.error("status: %s" % (event['status'],))
+         logging.error("error: %s" % (event['error'],))
+         logging.error("statusstr: %s" % (event['statusstr'],))
+
+      self.stop_reactor()
+
+   def run(self):
+      TestCase.run(self)
+      self.create_ami_factory(2)
+
+
+def main():
+   test = T38Test()
+   reactor.run()
+
+   if not test.passed:
+      return 1
+
+   return 0
+
+if __name__ == "__main__":
+   sys.exit(main() or 0)
+
diff --git a/tests/fax/pjsip/t38_with_auth/test-config.yaml b/tests/fax/pjsip/t38_with_auth/test-config.yaml
new file mode 100644
index 0000000..43cda18
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/test-config.yaml
@@ -0,0 +1,19 @@
+testinfo:
+    summary: 'Test faxing between PJSIP channels. Uses authorization.'
+    description: |
+        "This test starts two Asterisk instances and sends a fax between them
+         using the PJSIP channel driver - The endpoints use userpass
+         authentication."
+
+properties:
+    minversion: '13.3.1'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - custom : 'fax'
+        - asterisk : 'chan_pjsip'
+        - asterisk : 'res_pjsip_t38'
+    tags:
+        - pjsip
+        - fax
+
diff --git a/tests/fax/pjsip/tests.yaml b/tests/fax/pjsip/tests.yaml
index a192009..58bd614 100644
--- a/tests/fax/pjsip/tests.yaml
+++ b/tests/fax/pjsip/tests.yaml
@@ -1,6 +1,7 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 't38'
+    - test: 't38_with_auth'
     - test: 'directmedia_reinvite_t38'
     - test: 'gateway_t38_g711'
     - test: 'gateway_native_t38'

-- 
To view, visit https://gerrit.asterisk.org/22
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8fd9683dc1b61e7b1afd2b6ede857921beebb88
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Jonathan Rose <jrose at digium.com>



More information about the asterisk-dev mailing list