[asterisk-dev] Change in testsuite[master]: Testsuite: New test for FAX via PJSIP T38 with authentication

Joshua Colp (Code Review) asteriskteam at digium.com
Tue Apr 7 13:34:13 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: Testsuite: New test for FAX via PJSIP T38 with authentication
......................................................................


Testsuite: New test for FAX via PJSIP T38 with authentication

Add a test for PJSIP t38 with authentication based on normal t38 test
The test will start two instances of Asterisk. The first will originate
a PJSIP call with authentication to the second using an extension that
will run sendFax. The second will receive the call and direct it to an
extension that runs receiveFax. As the fax completes, user events are
issued to verify that the FAX completed successfully.

ASTERISK-24933
Reported by: Jonathan Rose
Change-Id: If37cf20857ae3c0b35e0637a0a2cb7e7d6226df6
---
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/send.tiff
A tests/fax/pjsip/t38_with_auth/test-config.yaml
M tests/fax/pjsip/tests.yaml
8 files changed, 188 insertions(+), 0 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Ashley Sanders: Looks good to me, but someone else must approve
  Joshua Colp: Verified



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..83e0d5b
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast1/extensions.conf
@@ -0,0 +1,7 @@
+[sendfax]
+exten => 1234,1,noop
+ same => n,SendFax(${ASTDATADIR}/send.tiff)
+
+exten => h,1,noop
+ same => 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..8d5dc7f
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/configs/ast2/extensions.conf
@@ -0,0 +1,6 @@
+[receivefax]
+exten => 1234,1,noop
+ same => n,ReceiveFax(${ASTDATADIR}/receive.tiff)
+
+exten => h,1,noop
+ same => 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 100755
index 0000000..ba2238f
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/run-test
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2015, Digium, Inc.
+Matthew Nicholson <mnicholson at digium.com>
+Jonathan Rose <jrose 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 shutil
+
+sys.path.append("lib/python")
+
+from twisted.internet import reactor
+from asterisk.test_case import TestCase
+
+LOGGER = logging.getLogger(__name__)
+
+
+class T38Test(TestCase):
+    """Test class for performing the test.
+
+    Manages files, originates FAX call, and monitors a user event to verify
+    that the fax completed successfully on the sender end of the call.
+    """
+
+    def __init__(self):
+        """Create Asterisk instances and prepare files."""
+
+        super(T38Test, self).__init__()
+        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):
+        """Post AMI Connection Operations - originate/registration
+
+        Upon connecting to AMI on the first Asterisk instance, originate
+        a call that will send the fax to the second Asterisk instance. Also
+        register for UserEvents.
+        """
+
+        if ami.id == 0:
+            ami.registerEvent('UserEvent', self.fax_result)
+            deferred = ami.originate("PJSIP/ast2-t38/sip:1234 at 127.0.0.2",
+                                     "sendfax", "1234", 1)
+            deferred.addErrback(self.handle_originate_failure)
+
+    def fax_result(self, ami, event):
+        """Verify FAX test results from user events"""
+
+        if event['userevent'] != 'FaxStatus':
+            return
+
+        if event['status'] == "SUCCESS":
+            self.passed = True
+        else:
+            LOGGER.error("Error sending fax through t38:")
+            LOGGER.error("Operation: %s" % (event['operation'],))
+            LOGGER.error("Status: %s" % (event['status'],))
+            LOGGER.error("Error: %s" % (event['error'],))
+            LOGGER.error("StatusStr: %s" % (event['statusstr'],))
+
+        self.stop_reactor()
+
+    def run(self):
+        """Run the test and create AMI factories for two instances"""
+        super(T38Test, self).run()
+        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/send.tiff b/tests/fax/pjsip/t38_with_auth/send.tiff
new file mode 100644
index 0000000..a5fb4fe
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/send.tiff
Binary files differ
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..ef43725
--- /dev/null
+++ b/tests/fax/pjsip/t38_with_auth/test-config.yaml
@@ -0,0 +1,23 @@
+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. Addresses a bug that caused a failure in faxes using
+         authentication while sending from a PJSIP endpoint detailed in
+         ASTERISK-24933"
+
+properties:
+    minversion: '13.4.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - custom : 'fax'
+        - asterisk : 'chan_pjsip'
+        - asterisk : 'res_pjsip_t38'
+    tags:
+        - pjsip
+        - fax
+    issues:
+        - jira: 'ASTERISk-24933'
+
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/28
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If37cf20857ae3c0b35e0637a0a2cb7e7d6226df6
Gerrit-PatchSet: 4
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Jonathan Rose <jrose at digium.com>
Gerrit-Reviewer: Ashley Sanders <asanders at digium.com>
Gerrit-Reviewer: Jonathan Rose <jrose at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-dev mailing list