[Asterisk-code-review] chan_iax2: Add tests for encryption with RSA authentication (testsuite[master])

N A asteriskteam at digium.com
Wed Oct 6 19:02:37 CDT 2021


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/16568 )


Change subject: chan_iax2: Add tests for encryption with RSA authentication
......................................................................

chan_iax2: Add tests for encryption with RSA authentication

Previously, RSA authentication in IAX2 did not allow encryption to be used.

This test ensures that MD5 and RSA authentication modes function properly
when encryption is used.

Change-Id: I6e4595b7b6166a83fae30beafeef237e2ecf1910
---
A tests/channels/iax2/encrypted-call-md5/configs/ast1/extensions.conf
A tests/channels/iax2/encrypted-call-md5/configs/ast1/iax.conf
A tests/channels/iax2/encrypted-call-md5/configs/ast2/cdr.conf
A tests/channels/iax2/encrypted-call-md5/configs/ast2/extensions.conf
A tests/channels/iax2/encrypted-call-md5/configs/ast2/iax.conf
A tests/channels/iax2/encrypted-call-md5/test-config.yaml
A tests/channels/iax2/encrypted-call-rsa/configs/ast1/extensions.conf
A tests/channels/iax2/encrypted-call-rsa/configs/ast1/iax.conf
A tests/channels/iax2/encrypted-call-rsa/configs/ast2/cdr.conf
A tests/channels/iax2/encrypted-call-rsa/configs/ast2/extensions.conf
A tests/channels/iax2/encrypted-call-rsa/configs/ast2/iax.conf
A tests/channels/iax2/encrypted-call-rsa/files/ast1/astvarlibdir/keys/test.key
A tests/channels/iax2/encrypted-call-rsa/files/ast2/astvarlibdir/keys/test.pub
A tests/channels/iax2/encrypted-call-rsa/test-config.yaml
M tests/channels/iax2/tests.yaml
15 files changed, 481 insertions(+), 0 deletions(-)



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

diff --git a/tests/channels/iax2/encrypted-call-md5/configs/ast1/extensions.conf b/tests/channels/iax2/encrypted-call-md5/configs/ast1/extensions.conf
new file mode 100644
index 0000000..6c995e9
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-md5/configs/ast1/extensions.conf
@@ -0,0 +1,8 @@
+[general]
+
+[globals]
+
+[iaxtest]
+
+exten => 1000,1,Answer()
+exten => 1000,n,Echo()
\ No newline at end of file
diff --git a/tests/channels/iax2/encrypted-call-md5/configs/ast1/iax.conf b/tests/channels/iax2/encrypted-call-md5/configs/ast1/iax.conf
new file mode 100644
index 0000000..11ef13c
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-md5/configs/ast1/iax.conf
@@ -0,0 +1,19 @@
+[general]
+
+bindport=4570
+bindaddr=127.0.0.1
+
+disallow=all
+allow=ulaw
+
+jitterbuffer=no
+forcejitterbuffer=no
+
+encryption=yes
+
+[guest70]
+type=user
+context=iaxtest
+auth=md5
+secret=passw0rd
+forceencryption=yes
diff --git a/tests/channels/iax2/encrypted-call-md5/configs/ast2/cdr.conf b/tests/channels/iax2/encrypted-call-md5/configs/ast2/cdr.conf
new file mode 100644
index 0000000..921793c
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-md5/configs/ast2/cdr.conf
@@ -0,0 +1,7 @@
+[general]
+unanswered=yes
+[csv]
+usegmtime=yes    ; log date/time in GMT.  Default is "no"
+loguniqueid=yes  ; log uniqueid.  Default is "no"
+loguserfield=yes ; log user field.  Default is "no"
+
diff --git a/tests/channels/iax2/encrypted-call-md5/configs/ast2/extensions.conf b/tests/channels/iax2/encrypted-call-md5/configs/ast2/extensions.conf
new file mode 100644
index 0000000..c3939af
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-md5/configs/ast2/extensions.conf
@@ -0,0 +1,9 @@
+[general]
+
+[globals]
+
+[iaxtest]
+
+exten => 1000,1,Answer()
+exten => 1000,n,Wait(1)
+exten => 1000,n,Hangup()
diff --git a/tests/channels/iax2/encrypted-call-md5/configs/ast2/iax.conf b/tests/channels/iax2/encrypted-call-md5/configs/ast2/iax.conf
new file mode 100644
index 0000000..c561f6d
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-md5/configs/ast2/iax.conf
@@ -0,0 +1,16 @@
+[general]
+
+bindport=4569
+bindaddr=127.0.0.1
+
+disallow=all
+allow=ulaw
+
+encryption=yes
+
+[guest69]
+type=user
+context=iaxtest
+auth=md5
+secret=passw0rd
+forceencryption=yes
diff --git a/tests/channels/iax2/encrypted-call-md5/test-config.yaml b/tests/channels/iax2/encrypted-call-md5/test-config.yaml
new file mode 100644
index 0000000..b6b9770
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-md5/test-config.yaml
@@ -0,0 +1,165 @@
+testinfo:
+    summary:     'Test a basic IAX2 call'
+    description: |
+        'This test initiates an IAX2 call between 2 instances of Asterisk.
+        The test only verifies that an IAX2 call is actually instantiated
+        between the two Asterisk instances and that proper records are
+        generated.'
+
+properties:
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk : 'cdr_csv'
+    tags:
+        - iax2
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.TestCaseModule'
+    modules:
+        -
+            config-section: originator
+            typename: 'pluggable_modules.Originator'
+        -
+            config-section: ami-config
+            typename: 'ami.AMIEventModule'
+        -
+            config-section: hangup-monitor
+            typename: 'pluggable_modules.HangupMonitor'
+        -
+            config-section: cdr-config
+            typename: 'cdr.CDRModule'
+        -
+            config-section: 'cel-config'
+            typename: 'ami.AMIEventModule'
+
+
+test-object-config:
+    asterisk-instances: 2
+    connect-ami: True
+
+originator:
+    trigger: 'ami_connect'
+    id: '0'
+    channel: 'IAX2/guest69:passw0rd at 127.0.0.1:4569/1000'
+    context: 'iaxtest'
+    exten: '1000'
+    priority: '1'
+    async: 'True'
+
+ami-config:
+    -
+        id: '0'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Newchannel'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+    -
+        id: '1'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Newchannel'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+    -
+        id: '0'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Hangup'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+    -
+        id: '1'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Hangup'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+
+hangup-monitor:
+    ids: '0'
+
+cdr-config:
+    -
+        id: 0
+        file: 'Master'
+        lines:
+            -
+                destination: '1000'
+                dcontext: 'iaxtest'
+                channel: 'IAX2/.*'
+                lastapp: 'Echo'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+    -
+        id: 1
+        file: 'Master'
+        lines:
+            -
+                destination: '1000'
+                dcontext: 'iaxtest'
+                channel: 'IAX2/.*'
+                lastapp: 'Hangup'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+
+cel-config:
+    -
+        id: '0'
+        type: 'cel'
+        conditions:
+            match:
+                Channel: 'IAX2/.*'
+        requirements:
+            -
+                match:
+                    EventName: CHAN_START
+            -
+                match:
+                    EventName: ANSWER
+            -
+                match:
+                    EventName: HANGUP
+            -
+                match:
+                    EventName: CHAN_END
+            -
+                match:
+                    EventName: LINKEDID_END
+    -
+        id: '1'
+        type: 'cel'
+        conditions:
+            match:
+                Channel: 'IAX2/.*'
+        requirements:
+            -
+                match:
+                    EventName: CHAN_START
+            -
+                match:
+                    EventName: ANSWER
+            -
+                match:
+                    EventName: HANGUP
+            -
+                match:
+                    EventName: CHAN_END
+            -
+                match:
+                    EventName: LINKEDID_END
diff --git a/tests/channels/iax2/encrypted-call-rsa/configs/ast1/extensions.conf b/tests/channels/iax2/encrypted-call-rsa/configs/ast1/extensions.conf
new file mode 100644
index 0000000..6c995e9
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/configs/ast1/extensions.conf
@@ -0,0 +1,8 @@
+[general]
+
+[globals]
+
+[iaxtest]
+
+exten => 1000,1,Answer()
+exten => 1000,n,Echo()
\ No newline at end of file
diff --git a/tests/channels/iax2/encrypted-call-rsa/configs/ast1/iax.conf b/tests/channels/iax2/encrypted-call-rsa/configs/ast1/iax.conf
new file mode 100644
index 0000000..c6ce08f
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/configs/ast1/iax.conf
@@ -0,0 +1,28 @@
+[general]
+
+bindport=4570
+bindaddr=127.0.0.1
+
+disallow=all
+allow=ulaw
+
+jitterbuffer=no
+forcejitterbuffer=no
+
+encryption=yes
+
+[guest70]
+type=user
+context=iaxtest
+auth=md5
+secret=passw0rd
+forceencryption=yes
+
+[toguest69]
+type=peer
+username=guest69
+host=127.0.0.1
+port=4569
+secret=passw0rd
+auth=rsa
+outkey=test
diff --git a/tests/channels/iax2/encrypted-call-rsa/configs/ast2/cdr.conf b/tests/channels/iax2/encrypted-call-rsa/configs/ast2/cdr.conf
new file mode 100644
index 0000000..921793c
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/configs/ast2/cdr.conf
@@ -0,0 +1,7 @@
+[general]
+unanswered=yes
+[csv]
+usegmtime=yes    ; log date/time in GMT.  Default is "no"
+loguniqueid=yes  ; log uniqueid.  Default is "no"
+loguserfield=yes ; log user field.  Default is "no"
+
diff --git a/tests/channels/iax2/encrypted-call-rsa/configs/ast2/extensions.conf b/tests/channels/iax2/encrypted-call-rsa/configs/ast2/extensions.conf
new file mode 100644
index 0000000..c3939af
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/configs/ast2/extensions.conf
@@ -0,0 +1,9 @@
+[general]
+
+[globals]
+
+[iaxtest]
+
+exten => 1000,1,Answer()
+exten => 1000,n,Wait(1)
+exten => 1000,n,Hangup()
diff --git a/tests/channels/iax2/encrypted-call-rsa/configs/ast2/iax.conf b/tests/channels/iax2/encrypted-call-rsa/configs/ast2/iax.conf
new file mode 100644
index 0000000..9fdbfdb
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/configs/ast2/iax.conf
@@ -0,0 +1,17 @@
+[general]
+
+bindport=4569
+bindaddr=127.0.0.1
+
+disallow=all
+allow=ulaw
+
+encryption=yes
+
+[guest69]
+type=user
+context=iaxtest
+auth=rsa
+secret=passw0rd
+forceencryption=yes
+inkeys=test
diff --git a/tests/channels/iax2/encrypted-call-rsa/files/ast1/astvarlibdir/keys/test.key b/tests/channels/iax2/encrypted-call-rsa/files/ast1/astvarlibdir/keys/test.key
new file mode 100644
index 0000000..417ef16
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/files/ast1/astvarlibdir/keys/test.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQCeDuRnTJWkht1ssoxcaD62nNkgQDxn6AMObAuBMcDK8WJzdlgl
+lnsoyJqDFNl1i3TZ1JW8GQLjwNZyKREsGE7UDj4eKWYgqKhdGjkuM9L8EI0y5GTj
+QClUokKrkFa0L5rQwbyw0m4doQpae3myjlGtKQIKUFtv0r78sprSBh/WUQIDAQAB
+AoGABdpxVO3+ILCp5IucLRPjNqoKVGpskkCCVHdl2av5Asr7pWD9lK7E8tay+iW8
+g+DdO+/md6fJdpu+lU22CBcCXEMgpIFgaPbo+6tKcLi4fgO00GhFZl2d6YRXDY8C
+XdaEgnI1lO05LtLpwCO8neIWTXn8B5cafHEitziWoDrwFf0CQQDKPjTCRAL9gO9T
+b9ExsWqwXEnSGWtjTdcy3LYTF0G15HP0rY6e/U5O4YT8sevWgl84hLquh50kqpt2
+0mKzal5jAkEAyBIXz+JDto0n63tpiyCKf6RmKWpOg0aJv+zF6URrvKfPYchymOag
+REfx7GZaUNd48emvE9fhEK/R2qbpTdLMuwJBALuy8BQ8Ouo79+JgLK8KEhKMFJdB
+sEEBxXAXF4SwWPQPiu7TBULZpQvgkiRUnKUBao5x4TCJ/HZDQPYOXDxXxDECQALu
+QOsKpXNHHg6VADbJgz3baqOwqvXBUsM89Kk2F13sF12XUhZrSm21oBWWajxE68Cf
+a7EeuG1GJgzN5Rz+uYECQQDIXC3bHXapjYR4wog2ANnTuYuxvmo9Zos6tuyj98aE
+OdAmJ2tAUL5Vfaj9Ndp9rtxOMV6Kg+fSeBfgihJimFQm
+-----END RSA PRIVATE KEY-----
diff --git a/tests/channels/iax2/encrypted-call-rsa/files/ast2/astvarlibdir/keys/test.pub b/tests/channels/iax2/encrypted-call-rsa/files/ast2/astvarlibdir/keys/test.pub
new file mode 100644
index 0000000..088fe33
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/files/ast2/astvarlibdir/keys/test.pub
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeDuRnTJWkht1ssoxcaD62nNkg
+QDxn6AMObAuBMcDK8WJzdlgllnsoyJqDFNl1i3TZ1JW8GQLjwNZyKREsGE7UDj4e
+KWYgqKhdGjkuM9L8EI0y5GTjQClUokKrkFa0L5rQwbyw0m4doQpae3myjlGtKQIK
+UFtv0r78sprSBh/WUQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/tests/channels/iax2/encrypted-call-rsa/test-config.yaml b/tests/channels/iax2/encrypted-call-rsa/test-config.yaml
new file mode 100644
index 0000000..3b761c4
--- /dev/null
+++ b/tests/channels/iax2/encrypted-call-rsa/test-config.yaml
@@ -0,0 +1,165 @@
+testinfo:
+    summary:     'Test a basic IAX2 call'
+    description: |
+        'This test initiates an IAX2 call between 2 instances of Asterisk.
+        The test only verifies that an IAX2 call is actually instantiated
+        between the two Asterisk instances and that proper records are
+        generated.'
+
+properties:
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk : 'cdr_csv'
+    tags:
+        - iax2
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.TestCaseModule'
+    modules:
+        -
+            config-section: originator
+            typename: 'pluggable_modules.Originator'
+        -
+            config-section: ami-config
+            typename: 'ami.AMIEventModule'
+        -
+            config-section: hangup-monitor
+            typename: 'pluggable_modules.HangupMonitor'
+        -
+            config-section: cdr-config
+            typename: 'cdr.CDRModule'
+        -
+            config-section: 'cel-config'
+            typename: 'ami.AMIEventModule'
+
+
+test-object-config:
+    asterisk-instances: 2
+    connect-ami: True
+
+originator:
+    trigger: 'ami_connect'
+    id: '0'
+    channel: 'IAX2/toguest69/1000'
+    context: 'iaxtest'
+    exten: '1000'
+    priority: '1'
+    async: 'True'
+
+ami-config:
+    -
+        id: '0'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Newchannel'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+    -
+        id: '1'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Newchannel'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+    -
+        id: '0'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Hangup'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+    -
+        id: '1'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'Hangup'
+        requirements:
+            match:
+                Channel: 'IAX2/.*'
+
+hangup-monitor:
+    ids: '0'
+
+cdr-config:
+    -
+        id: 0
+        file: 'Master'
+        lines:
+            -
+                destination: '1000'
+                dcontext: 'iaxtest'
+                channel: 'IAX2/.*'
+                lastapp: 'Echo'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+    -
+        id: 1
+        file: 'Master'
+        lines:
+            -
+                destination: '1000'
+                dcontext: 'iaxtest'
+                channel: 'IAX2/.*'
+                lastapp: 'Hangup'
+                disposition: 'ANSWERED'
+                amaflags: 'DOCUMENTATION'
+
+cel-config:
+    -
+        id: '0'
+        type: 'cel'
+        conditions:
+            match:
+                Channel: 'IAX2/.*'
+        requirements:
+            -
+                match:
+                    EventName: CHAN_START
+            -
+                match:
+                    EventName: ANSWER
+            -
+                match:
+                    EventName: HANGUP
+            -
+                match:
+                    EventName: CHAN_END
+            -
+                match:
+                    EventName: LINKEDID_END
+    -
+        id: '1'
+        type: 'cel'
+        conditions:
+            match:
+                Channel: 'IAX2/.*'
+        requirements:
+            -
+                match:
+                    EventName: CHAN_START
+            -
+                match:
+                    EventName: ANSWER
+            -
+                match:
+                    EventName: HANGUP
+            -
+                match:
+                    EventName: CHAN_END
+            -
+                match:
+                    EventName: LINKEDID_END
diff --git a/tests/channels/iax2/tests.yaml b/tests/channels/iax2/tests.yaml
index 779f2cd..f92c173 100644
--- a/tests/channels/iax2/tests.yaml
+++ b/tests/channels/iax2/tests.yaml
@@ -3,3 +3,5 @@
     - test: 'basic-call'
     - test: 'hangupcause'
     - test: 'acl_call'
+    - test: 'encrypted-call-md5'
+    - test: 'encrypted-call-rsa'

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/16568
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Change-Id: I6e4595b7b6166a83fae30beafeef237e2ecf1910
Gerrit-Change-Number: 16568
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211006/748c19c6/attachment-0001.html>


More information about the asterisk-code-review mailing list