[Asterisk-code-review] ARI event filtering (testsuite[13])

Friendly Automation asteriskteam at digium.com
Wed Feb 20 11:35:31 CST 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/10985 )

Change subject: ARI event filtering
......................................................................

ARI event filtering

Added several tests that check to make sure the allowed and disallowed event
filtering mechanism works for an ARI application.

ASTERISK-28106

Change-Id: I29e24c9386f9638484a816a519948a564c821a8a
---
A tests/rest_api/applications/event-filter/allowed/configs/ast1/extensions.conf
A tests/rest_api/applications/event-filter/allowed/test-config.yaml
A tests/rest_api/applications/event-filter/both/configs/ast1/extensions.conf
A tests/rest_api/applications/event-filter/both/test-config.yaml
A tests/rest_api/applications/event-filter/disallowed/configs/ast1/extensions.conf
A tests/rest_api/applications/event-filter/disallowed/test-config.yaml
A tests/rest_api/applications/event-filter/tests.yaml
M tests/rest_api/applications/tests.yaml
8 files changed, 273 insertions(+), 0 deletions(-)

Approvals:
  Joshua C. Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/tests/rest_api/applications/event-filter/allowed/configs/ast1/extensions.conf b/tests/rest_api/applications/event-filter/allowed/configs/ast1/extensions.conf
new file mode 100644
index 0000000..59c7f03
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/allowed/configs/ast1/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Echo()
+	same => n,Hangup()
diff --git a/tests/rest_api/applications/event-filter/allowed/test-config.yaml b/tests/rest_api/applications/event-filter/allowed/test-config.yaml
new file mode 100644
index 0000000..4d34d38
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/allowed/test-config.yaml
@@ -0,0 +1,82 @@
+testinfo:
+    summary: 'Test the event type allowed filter'
+    description: |
+        Subscribe to all events. Then create an event type allowed filter that
+        only allows StasisStart and StasisEnd events to be sent to the app.
+        Check to make sure those events are received, while also checking that
+        other event types are not.
+
+properties:
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : app_echo
+    tags:
+        - ARI
+
+test-modules:
+    test-object:
+        config-section: test-object
+        typename: ari.AriBaseTestObject
+    modules:
+        -   typename: pluggable_modules.EventActionModule
+            config-section: event-actions
+
+test-object:
+    subscribe-all: True
+
+event-actions:
+    -
+        ari-start:
+        ari-requests:
+            -
+                method: 'put'
+                uri: 'applications/testsuite/eventFilter'
+                body: { 'allowed': [ { 'type': 'StasisStart' }, { 'type': 'StasisEnd' } ]}
+            -
+                method: 'post'
+                uri: 'channels'
+                params:
+                    app: 'testsuite'
+                    endpoint: 'Local/s at default'
+                    channelId: 'chan1'
+    -
+        ari-events:
+            match:
+                type: 'ChannelCreated'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 0
+    -
+        ari-events:
+            match:
+                type: 'ChannelDestroyed'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 0
+    -
+        ari-events:
+            match:
+                type: 'StasisStart'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 1
+        ari-requests:
+            -
+                method: 'delete'
+                uri: 'channels/chan1'
+    -
+        ari-events:
+            match:
+                type: 'StasisEnd'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 1
+        stop_test:
diff --git a/tests/rest_api/applications/event-filter/both/configs/ast1/extensions.conf b/tests/rest_api/applications/event-filter/both/configs/ast1/extensions.conf
new file mode 100644
index 0000000..59c7f03
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/both/configs/ast1/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Echo()
+	same => n,Hangup()
diff --git a/tests/rest_api/applications/event-filter/both/test-config.yaml b/tests/rest_api/applications/event-filter/both/test-config.yaml
new file mode 100644
index 0000000..0f7b4c9
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/both/test-config.yaml
@@ -0,0 +1,85 @@
+testinfo:
+    summary: 'Test setting both the event type allowed and disallowed filters'
+    description: |
+        Subscribe to all events. Then create an event type allowed filter that
+        only allows StasisStart, StasisEnd, and ChannelCreated events. At the
+        same time create a disallowed filter that does not allow ChannelCreated
+        events (overrides that which is specified in allowed). Check to make
+        sure StasisStart/End events are received, but not the ChannelCreated
+        event (or others).
+
+properties:
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : app_echo
+    tags:
+        - ARI
+
+test-modules:
+    test-object:
+        config-section: test-object
+        typename: ari.AriBaseTestObject
+    modules:
+        -   typename: pluggable_modules.EventActionModule
+            config-section: event-actions
+
+test-object:
+    subscribe-all: True
+
+event-actions:
+    -
+        ari-start:
+        ari-requests:
+            -
+                method: 'put'
+                uri: 'applications/testsuite/eventFilter'
+                body: { 'allowed': [ { 'type': 'StasisStart' }, { 'type': 'StasisEnd' },
+                { 'type': 'ChannelCreated' } ], 'disallowed': [ { 'type': 'ChannelCreated' } ]}
+            -
+                method: 'post'
+                uri: 'channels'
+                params:
+                    app: 'testsuite'
+                    endpoint: 'Local/s at default'
+                    channelId: 'chan1'
+    -
+        ari-events:
+            match:
+                type: 'ChannelCreated'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 0
+    -
+        ari-events:
+            match:
+                type: 'ChannelDestroyed'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 0
+    -
+        ari-events:
+            match:
+                type: 'StasisStart'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 1
+        ari-requests:
+            -
+                method: 'delete'
+                uri: 'channels/chan1'
+    -
+        ari-events:
+            match:
+                type: 'StasisEnd'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 1
+        stop_test:
diff --git a/tests/rest_api/applications/event-filter/disallowed/configs/ast1/extensions.conf b/tests/rest_api/applications/event-filter/disallowed/configs/ast1/extensions.conf
new file mode 100644
index 0000000..59c7f03
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/disallowed/configs/ast1/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => s,1,NoOp()
+	same => n,Answer()
+	same => n,Echo()
+	same => n,Hangup()
diff --git a/tests/rest_api/applications/event-filter/disallowed/test-config.yaml b/tests/rest_api/applications/event-filter/disallowed/test-config.yaml
new file mode 100644
index 0000000..ef2a16d
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/disallowed/test-config.yaml
@@ -0,0 +1,82 @@
+testinfo:
+    summary: 'Test the event type disallowed filter'
+    description: |
+        Subscribe to all events. Then create an event type disallowed filter
+        that does not allow ChannelCreated and ChannelDestroyed events to be
+        sent to the app. Check to make sure those events are not and also make
+        sure other event types are.
+
+properties:
+    dependencies:
+        - python : autobahn.websocket
+        - python : requests
+        - python : twisted
+        - python : starpy
+        - asterisk : res_ari_channels
+        - asterisk : app_echo
+    tags:
+        - ARI
+
+test-modules:
+    test-object:
+        config-section: test-object
+        typename: ari.AriBaseTestObject
+    modules:
+        -   typename: pluggable_modules.EventActionModule
+            config-section: event-actions
+
+test-object:
+    subscribe-all: True
+
+event-actions:
+    -
+        ari-start:
+        ari-requests:
+            -
+                method: 'put'
+                uri: 'applications/testsuite/eventFilter'
+                body: { 'disallowed': [ { 'type': 'ChannelCreated' }, { 'type': 'ChannelDestroyed' } ]}
+            -
+                method: 'post'
+                uri: 'channels'
+                params:
+                    app: 'testsuite'
+                    endpoint: 'Local/s at default'
+                    channelId: 'chan1'
+    -
+        ari-events:
+            match:
+                type: 'ChannelCreated'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 0
+    -
+        ari-events:
+            match:
+                type: 'ChannelDestroyed'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 0
+    -
+        ari-events:
+            match:
+                type: 'StasisStart'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 1
+        ari-requests:
+            -
+                method: 'delete'
+                uri: 'channels/chan1'
+    -
+        ari-events:
+            match:
+                type: 'StasisEnd'
+                application: 'testsuite'
+                channel:
+                    id: 'chan1'
+            count: 1
+        stop_test:
diff --git a/tests/rest_api/applications/event-filter/tests.yaml b/tests/rest_api/applications/event-filter/tests.yaml
new file mode 100644
index 0000000..5d4a9a4
--- /dev/null
+++ b/tests/rest_api/applications/event-filter/tests.yaml
@@ -0,0 +1,5 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'allowed'
+    - test: 'both'
+    - test: 'disallowed'
diff --git a/tests/rest_api/applications/tests.yaml b/tests/rest_api/applications/tests.yaml
index 0ed0bf6..0c74707 100644
--- a/tests/rest_api/applications/tests.yaml
+++ b/tests/rest_api/applications/tests.yaml
@@ -1,6 +1,7 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 'errors'
+    - dir: 'event-filter'
     - dir: 'subscribe-endpoint'
     - test: 'subscribe-all'
     - test: 'subscribe-all-bridge'

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

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I29e24c9386f9638484a816a519948a564c821a8a
Gerrit-Change-Number: 10985
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua C. Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190220/902c4807/attachment-0001.html>


More information about the asterisk-code-review mailing list