├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── docker ├── Dockerfile.centos7 ├── Dockerfile.debian10 ├── Dockerfile.debian11 ├── Dockerfile.debian12 └── Dockerfile.debian9 ├── etc ├── config ├── excludeunits.txt.centos7 ├── excludeunits.txt.debian10 └── excludeunits.txt.debian9 ├── ktestsctl ├── libs └── utils └── units ├── tasync0001 ├── README.md ├── kamailio-tasync0001-inc.cfg ├── kamailio-tasync0001.cfg └── tasync0001.sh ├── tauthx0001 ├── README.md ├── kamailio-tauthx0001.cfg └── tauthx0001.sh ├── tauthx0002 ├── README.md ├── kamailio-tauthx0002.cfg ├── kamailio-tauthx0002.lua └── tauthx0002.sh ├── tavpop0001 ├── README.md ├── kamailio-tavpop0001.cfg └── tavpop0001.sh ├── tcfgxx0001 ├── README.md └── tcfgxx0001.sh ├── tcfgxx0002 ├── README.md └── tcfgxx0002.sh ├── tcfgxx0003 ├── README.md ├── kamailio-tcfgxx0003.cfg └── tcfgxx0003.sh ├── tgeoip0001 ├── README.md ├── kamailio-tgeoip0001.cfg └── tgeoip0001.sh ├── tgroup0001 ├── README.md ├── kamailio-tgroup0001.cfg └── tgroup0001.sh ├── thacxx0001 ├── README.md ├── http_server.py ├── kamailio-thacxx0001.cfg └── thacxx0001.sh ├── thacxx0002 ├── README.md ├── http_server.py ├── kamailio-thacxx0002.cfg └── thacxx0002.sh ├── thacxx0003 ├── README.md ├── http_server.py ├── kamailio-thacxx0003.cfg └── thacxx0003.sh ├── thacxx0004 ├── README.md ├── http_server.py ├── kamailio-thacxx0004.cfg └── thacxx0004.sh ├── thacxx0005 ├── README.md ├── http_server.py ├── kamailio-thacxx0005.cfg ├── thacxx0005.sh ├── uac.xml └── uas.xml ├── thacxx0006 ├── README.md ├── http_server.py ├── kamailio-thacxx0006.cfg ├── thacxx0006.sh ├── uac.xml └── uas.xml ├── thttpc0001 ├── README.md ├── http_server.py ├── kamailio-thttpc0001.cfg └── thttpc0001.sh ├── thttpc0002 ├── README.md ├── http_server.py ├── kamailio-thttpc0002.cfg └── thttpc0002.sh ├── tlcust0001 ├── README.md ├── kamailio-tlcust0001.cfg └── tlcust0001.sh ├── tmodxx0001 ├── README.md ├── kamailio-allmods.cfg └── tmodxx0001.sh ├── tmtree0001 ├── README.md ├── kamailio-tmtree0001.cfg └── tmtree0001.sh ├── tphonu0001 ├── README.md ├── kamailio-tphonu0001.cfg └── tphonu0001.sh ├── tpvxxx0001 ├── README.md ├── kamailio-tpvxxx0001.cfg └── tpvxxx0001.sh ├── tregexxx0001 ├── README.md ├── kamailio-tregexxx0001.cfg ├── regex_group ├── regex_groups ├── regex_groups_1 ├── regex_groups_2 └── tregexxx0001.sh ├── tregxx0001 ├── README.md ├── kamailio-tregxx0001-inc ├── kamailio-tregxx0001.cfg └── tregxx0001.sh ├── tregxx0002 ├── README.md ├── kamailio-tregxx0002.cfg ├── kamailio-tregxx0002.lua └── tregxx0002.sh ├── tsiput0001 ├── README.md ├── kamailio-tsiput0001.cfg └── tsiput0001.sh ├── tsjlua0001 ├── README.md ├── kamailio-tsjlua0001.cfg ├── kamailio-tsjlua0001.lua └── tsjlua0001.sh ├── tsjson0001 ├── README.md ├── kamailio-tsjson0001.cfg └── tsjson0001.sh ├── ttlsxx0001 ├── README.md └── ttlsxx0001.sh ├── tuacxx0001 ├── README.md ├── kamailio-tuacxx0001.cfg └── tuacxx0001.sh └── tulocx0001 ├── README.md └── tulocx0001.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # vi swaps 2 | .*.swp 3 | .*.swo 4 | # Emacs backup files 5 | *~ 6 | # Emacs file locks 7 | .#* 8 | # vscode tmp files 9 | .vscode 10 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.6.0 4 | hooks: 5 | - id: trailing-whitespace 6 | - id: check-merge-conflict 7 | - id: mixed-line-ending 8 | - id: end-of-file-fixer 9 | - repo: https://github.com/koalaman/shellcheck-precommit 10 | rev: v0.10.0 11 | hooks: 12 | - id: shellcheck 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Test Units For Kamailio SIP Server # 2 | 3 | Test framework with a set of unit tests for Kamailio SIP Server. It targets the use 4 | within a Docker container. 5 | 6 | Read more about Kamailio at: 7 | 8 | * https://www.kamailio.org 9 | 10 | ## The Test Framework ## 11 | 12 | The tests can be run using the command line tool `ktestsctl`. Run it without any parameter 13 | in order to see available options. 14 | 15 | A unit test is stored in its own directory inside the subfolder `units/`. The name of the 16 | directory is considered to be the name of the unit. 17 | 18 | The name of a unit test has the format `txxxxxnnnn`, the rules being: 19 | 20 | * `t` - the first character in the name (`t` from `test`) 21 | * `xxxx` - any five characters (use lower case letters) that should identify a group of tests 22 | (e.g., `cfgxx` is used to identify tests related to default `kamailio.cfg`) 23 | * `nnnn` - four digits to assign to different unit tests in the same group, use zeros to pad 24 | in order to have always four digits (e.g., `0001`) 25 | 26 | Example of full unit test name: `tcfgxx0001`. 27 | 28 | Inside each unit directory should be at least two files: 29 | 30 | * `unitname.sh` - an executable shell script to be used to run the unit (e.g., `tcfgxx0001.sh`) 31 | * `README.md` - to contain the description for the unit test 32 | 33 | The shell script is executed inside the unit directory by `ktestsctl`. 34 | 35 | The `README.md` is a text file in `markdown` format. It should have a line that starts with 36 | `Summary: ` and provides a short description of the unit test. The text in the line after 37 | `Summary: ` is used by `ktestsctl` when writing the unit tests execution report. 38 | 39 | The framework has a configuration file located at `etc/config`. This is a shell script expected 40 | to have lines with `VARIABLE=value`, allowing to set paths to the applications used by 41 | unit scripts. 42 | 43 | Useful shell functions that might be handy to use in units are stored inside files from 44 | `lib` subfolder, like: 45 | 46 | * `lib/utils` - common utility functions 47 | 48 | The Dockerfiles that can be used to build Docker images to run the unit tests are located in 49 | `docker` subfolder. These are: 50 | 51 | * `docker/Dockerfile.debian10` - container build with Debian 10.x (Buster) deploying Kamailio installed 52 | from source code. The directory with Kamailio source code is copied from local disk into the 53 | container 54 | * `docker/Dockerfile.debian9` - container build with Debian 9.x (Stretch) deploying Kamailio installed 55 | from source code. The directory with Kamailio source code is copied from local disk into the 56 | container 57 | * `docker/Dockerfile.centos7` - container build with CentOS 7 deploying Kamailio installed 58 | from source code. The directory with Kamailio source code is copied from local disk into the 59 | container 60 | 61 | 62 | ### Tools For Unit Tests ### 63 | 64 | Following tools are installed inside the container and can be used to create test units: 65 | 66 | * `awk` 67 | * `coreutils` package 68 | * `curl` 69 | * `gdb` (requires to run `docker` with `--cap-add=SYS_PTRACE`) 70 | * `grep` 71 | * `jq` 72 | * `sed` 73 | * `sipp` (`sip-tester`) 74 | * `sipsak` (installed from git) 75 | 76 | 77 | ## Running Unit Tests ## 78 | 79 | ### Dependencies ### 80 | 81 | * `docker` - it has to be installed in order to follow the next instructions 82 | 83 | ### Installation ### 84 | 85 | * create a directory where to store the resources and go to it 86 | 87 | ``` 88 | mkdir kamailio-testing 89 | cd kamailio-testing 90 | ``` 91 | 92 | * clone the `kamailio-tests` git repository 93 | 94 | ``` 95 | git clone https://github.com/kamailio/kamailio-tests 96 | ``` 97 | 98 | * clone the `kamailio` git repository 99 | 100 | ``` 101 | git clone https://github.com/kamailio/kamailio 102 | ``` 103 | 104 | * copy desired Dockerfile in the current folder 105 | 106 | Next example shows the use of the docker file for Debian 9.x. 107 | 108 | ``` 109 | cp kamailio-tests/docker/Dockerfile.debian9 Dockerfile 110 | ``` 111 | 112 | * build the Docker image 113 | 114 | The name of the image can be changed, next example sets a name suggesting 115 | it is based on Debian 9.x: 116 | 117 | ``` 118 | docker build -t kamailio-tests-deb9x . 119 | ``` 120 | 121 | ### Execute Unit Tests ### 122 | 123 | The `Dockerfile` defines the `ENTRYPOINT` to the path of `ktestsctl`: 124 | 125 | ``` 126 | ENTRYPOINT ["/usr/local/src/kamailio-tests/ktestsctl"] 127 | ``` 128 | 129 | With the default `Dockerfile`, the next command is running all unit tests: 130 | 131 | ``` 132 | docker run kamailio-tests-deb9x 133 | ``` 134 | The default option is `-m` (create mysql database). 135 | 136 | You can specify other options for `ktestsctl` by passing them to the Docker run command. 137 | 138 | For example, run the unit tests in silent mode: 139 | 140 | ``` 141 | docker run kamailio-tests-deb9x -q run 142 | ``` 143 | 144 | Example running only default `kamailio.cfg` related unit tests: 145 | 146 | ``` 147 | docker run kamailio-tests-deb9x run tcfgxx 148 | ``` 149 | 150 | Running `ktestsctl` with `-w` option requires to use docker in interactive 151 | mode: 152 | 153 | ``` 154 | docker run -i kamailio-tests-deb9x run -w 155 | ``` 156 | 157 | To stop a running container: 158 | 159 | ``` 160 | docker ps 161 | docker stop 162 | ``` 163 | 164 | ### Excluding Units ### 165 | 166 | You can exclude some units to be launched by listing them, one per line, in 167 | `etc/excludeunits.txt.DISTRIBUTION` (e.g. `etc/excludeunits.txt.centos7`), 168 | and then rebuilding the image. 169 | 170 | ## Contributing ## 171 | 172 | Contributions are more than welcome, recommended way is to do pull requests. 173 | 174 | ## Support ## 175 | 176 | Mailing list: 177 | 178 | * 179 | -------------------------------------------------------------------------------- /docker/Dockerfile.centos7: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | RUN groupadd -r mysql && useradd -r -g mysql mysql 4 | 5 | RUN yum update -y && yum install -y --setopt=tsflags=nodocs epel-release && \ 6 | yum install -y --setopt=tsflags=nodocs which gcc make bison curl-devel \ 7 | expat-devel flex hiredis-devel \ 8 | jansson-devel json-c-devel libevent-devel libxml2-devel \ 9 | lksctp-tools-devel lm_sensors-devel mysql-devel net-snmp-devel \ 10 | openldap-devel openssl-devel pcre-devel perl-ExtUtils-Embed perl-devel \ 11 | postgresql-devel libconfuse-devel python-devel sqlite-devel unixODBC-devel \ 12 | zlib-devel lua-devel rpm-build erlang erlang-erl_interface db4-devel \ 13 | hiredis-devel GeoIP-devel libmemcached-devel mod_perl-devel glib2-devel \ 14 | libpurple-devel libunistring-devel xmlrpc-c-devel iputils git \ 15 | libuuid-devel systemd-devel squirrel-devel uuid-devel librabbitmq-devel \ 16 | gcc-c++ autoconf automake wget mono-devel mongodb-devel mongo-c-driver \ 17 | mongo-c-driver-devel radiusclient-ng-devel libmaxminddb-devel libev-devel \ 18 | openssl python3-devel ruby-devel mosquitto-devel libmnl-devel nc luarocks 19 | 20 | ENV MYSQL_ROOT_PASSWORD=ktestsrootpw 21 | 22 | # From https://github.com/CentOS/CentOS-Dockerfiles/blob/master/mariadb/centos7/Dockerfile 23 | RUN yum -y install --setopt=tsflags=nodocs epel-release && \ 24 | yum -y install --setopt=tsflags=nodocs mariadb-server bind-utils pwgen psmisc hostname && \ 25 | yum -y erase vim-minimal && \ 26 | yum -y update && yum clean all 27 | 28 | # Install cjson 29 | RUN luarocks install lua-cjson 30 | 31 | WORKDIR /usr/local/src 32 | RUN git clone -b 0.9.7 https://github.com/nils-ohlmeier/sipsak 33 | WORKDIR /usr/local/src/sipsak 34 | RUN autoreconf --install 35 | RUN ./configure 36 | RUN make 37 | RUN make install 38 | 39 | # RUN mkdir -p /usr/local/src/data/GeoLite2 40 | # RUN mkdir -p /usr/local/src/tmp 41 | # COPY GeoLite2-City.tar.gz /usr/local/src/tmp/GeoLite2-City.tar.gz 42 | # WORKDIR /usr/local/src/tmp 43 | # RUN tar xvfz GeoLite2-City.tar.gz 44 | # RUN mv GeoLite2-City_*/*.* ../data/GeoLite2/ 45 | # WORKDIR /usr/local/src 46 | # RUN rm -rf tmp 47 | 48 | COPY kamailio /usr/local/src/kamailio 49 | WORKDIR /usr/local/src/kamailio 50 | RUN make JAVA_HOME=/usr/lib/jvm/java-gcj RADCLI=1 exclude_modules="stirshaken secsipid_proc jwt lwsc db_cassandra db_oracle dnssec ndb_cassandra nsq osp app_java acc_radius auth_radius peering misc_radius phonenum rtp_media_server kafka secsipid microhttpd" cfg 51 | RUN make JAVA_HOME=/usr/lib/jvm/java-gcj RADCLI=1 Q=0 CC_EXTRA_OPTS="-Wall" all 52 | RUN make JAVA_HOME=/usr/lib/jvm/java-gcj RADCLI=1 install 53 | WORKDIR src/modules/tls 54 | RUN make install-tls-cert 55 | 56 | ENV DBENGINE=MYSQL 57 | ENV DBRWPW=kamailiorw 58 | ENV DBROOTPW=ktestsrootpw 59 | 60 | # Moved down here for convenience 61 | RUN mysql_install_db --user=mysql 62 | 63 | COPY kamailio-tests /usr/local/src/kamailio-tests 64 | COPY kamailio-tests/etc/excludeunits.txt.centos7 /usr/local/src/kamailio-tests/excludeunits.txt 65 | WORKDIR /usr/local/src/kamailio-tests 66 | 67 | ENTRYPOINT ["/usr/local/src/kamailio-tests/ktestsctl"] 68 | CMD ["-m", "run"] 69 | -------------------------------------------------------------------------------- /docker/Dockerfile.debian10: -------------------------------------------------------------------------------- 1 | FROM debian:buster 2 | 3 | RUN groupadd -r mysql && useradd -r -g mysql mysql 4 | 5 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes apt-utils \ 6 | autoconf gcc g++ make procps \ 7 | coreutils ctags curl gawk gdb git jq lynx netcat ngrep sed sip-tester vim wget \ 8 | bison \ 9 | debhelper \ 10 | default-libmysqlclient-dev \ 11 | dh-systemd \ 12 | docbook-xml \ 13 | docbook2x \ 14 | dpkg-dev \ 15 | erlang-dev \ 16 | flex \ 17 | libbson-dev \ 18 | libconfuse-dev \ 19 | libcurl4-openssl-dev \ 20 | libdb-dev \ 21 | libev-dev \ 22 | libevent-dev \ 23 | libexpat1-dev \ 24 | libgeoip-dev \ 25 | libhiredis-dev \ 26 | libjansson-dev \ 27 | libjson-c-dev \ 28 | libldap2-dev \ 29 | liblua5.1-0-dev \ 30 | libmaxminddb-dev \ 31 | libmemcached-dev \ 32 | libmnl-dev \ 33 | libmongoc-dev \ 34 | libmono-2.0-dev \ 35 | libmosquitto-dev \ 36 | libncurses5-dev \ 37 | libpcre3-dev \ 38 | libperl-dev \ 39 | libphonenumber-dev \ 40 | libpq-dev \ 41 | librabbitmq-dev \ 42 | libradcli-dev \ 43 | libreadline-dev \ 44 | librdkafka-dev \ 45 | libsasl2-dev \ 46 | libsctp-dev \ 47 | libsnmp-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | libsystemd-dev \ 51 | libunistring-dev \ 52 | libxml2-dev \ 53 | libwebsockets-dev \ 54 | lua-cjson \ 55 | openssl \ 56 | pkg-config \ 57 | python \ 58 | python-dev \ 59 | python3-dev \ 60 | ruby-dev \ 61 | unixodbc-dev \ 62 | uuid-dev \ 63 | xsltproc \ 64 | zlib1g-dev 65 | 66 | ENV MYSQL_ROOT_PASSWORD=ktestsrootpw 67 | RUN DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes default-mysql-client default-mysql-server 68 | RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \ 69 | && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ 70 | && chmod 777 /var/run/mysqld \ 71 | && find /etc/mysql/ -name '*.cnf' -print0 \ 72 | | xargs -0 grep -lZE '^(bind-address|log)' \ 73 | | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \ 74 | && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf 75 | RUN mysql_install_db --user=mysql 76 | 77 | WORKDIR /usr/local/src 78 | RUN git clone -b 0.9.7 https://github.com/nils-ohlmeier/sipsak 79 | WORKDIR /usr/local/src/sipsak 80 | RUN autoreconf --install 81 | RUN ./configure 82 | RUN make 83 | RUN make install 84 | 85 | # RUN mkdir -p /usr/local/src/data/GeoLite2 86 | # RUN mkdir -p /usr/local/src/tmp 87 | # COPY GeoLite2-City.tar.gz /usr/local/src/tmp/GeoLite2-City.tar.gz 88 | # WORKDIR /usr/local/src/tmp 89 | # RUN tar xvfz GeoLite2-City.tar.gz 90 | # RUN mv GeoLite2-City_*/*.* ../data/GeoLite2/ 91 | # WORKDIR /usr/local/src 92 | # RUN rm -rf tmp 93 | 94 | COPY kamailio /usr/local/src/kamailio 95 | WORKDIR /usr/local/src/kamailio 96 | RUN make RADCLI=1 exclude_modules="db_cassandra db_oracle dnssec ndb_cassandra nsq osp app_java rtp_media_server secsipid secsipid_proc stirshaken jwt nats ruxc microhttpd" cfg 97 | RUN make RADCLI=1 Q=0 CC_EXTRA_OPTS="-Wall" all 98 | RUN make RADCLI=1 install 99 | WORKDIR src/modules/tls 100 | RUN make install-tls-cert 101 | 102 | ENV DBENGINE=MYSQL 103 | ENV DBRWPW=kamailiorw 104 | ENV DBROOTPW=ktestsrootpw 105 | 106 | RUN pwd 107 | RUN ls -la /usr/local/src 108 | 109 | COPY kamailio-tests /usr/local/src/kamailio-tests 110 | COPY kamailio-tests/etc/excludeunits.txt.debian10 /usr/local/src/kamailio-tests/excludeunits.txt 111 | RUN ls -la /usr/local/src/kamailio-tests 112 | RUN ls -la /usr/local/src/kamailio-tests/units 113 | WORKDIR /usr/local/src/kamailio-tests 114 | 115 | ENTRYPOINT ["/usr/local/src/kamailio-tests/ktestsctl"] 116 | CMD ["-m", "run"] 117 | -------------------------------------------------------------------------------- /docker/Dockerfile.debian11: -------------------------------------------------------------------------------- 1 | FROM debian:bullseye 2 | 3 | RUN groupadd -r mysql && useradd -r -g mysql mysql 4 | 5 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes apt-utils \ 6 | autoconf gcc g++ make procps \ 7 | coreutils exuberant-ctags curl gawk gdb git jq lynx netcat ngrep sed sip-tester vim wget \ 8 | bison libtool \ 9 | debhelper \ 10 | default-libmysqlclient-dev \ 11 | docbook-xml \ 12 | docbook2x \ 13 | dpkg-dev \ 14 | erlang-dev \ 15 | flex \ 16 | libbson-dev \ 17 | libconfuse-dev \ 18 | libcurl4-openssl-dev \ 19 | libdb-dev \ 20 | libev-dev \ 21 | libevent-dev \ 22 | libexpat1-dev \ 23 | libgeoip-dev \ 24 | libhiredis-dev \ 25 | libjansson-dev \ 26 | libjson-c-dev \ 27 | libldap2-dev \ 28 | liblua5.1-0-dev \ 29 | libmaxminddb-dev \ 30 | libmemcached-dev \ 31 | libmnl-dev \ 32 | libmongoc-dev \ 33 | libmono-2.0-dev \ 34 | libmosquitto-dev \ 35 | libncurses5-dev \ 36 | libpcre3-dev \ 37 | libperl-dev \ 38 | libphonenumber-dev \ 39 | libpq-dev \ 40 | librabbitmq-dev \ 41 | libradcli-dev \ 42 | libreadline-dev \ 43 | librdkafka-dev \ 44 | libsasl2-dev \ 45 | libsctp-dev \ 46 | libsnmp-dev \ 47 | libsqlite3-dev \ 48 | libssl-dev \ 49 | libsystemd-dev \ 50 | libunistring-dev \ 51 | libxml2-dev \ 52 | libwebsockets-dev \ 53 | lua-cjson \ 54 | openssl \ 55 | pkg-config \ 56 | python \ 57 | python-dev \ 58 | python3-dev \ 59 | ruby-dev \ 60 | unixodbc-dev \ 61 | uuid-dev \ 62 | xsltproc \ 63 | zlib1g-dev 64 | 65 | ENV MYSQL_ROOT_PASSWORD=ktestsrootpw 66 | RUN DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes default-mysql-client default-mysql-server 67 | RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \ 68 | && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ 69 | && chmod 777 /var/run/mysqld \ 70 | && find /etc/mysql/ -name '*.cnf' -print0 \ 71 | | xargs -0 grep -lZE '^(bind-address|log)' \ 72 | | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \ 73 | && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf 74 | RUN mysql_install_db --user=mysql 75 | 76 | WORKDIR /usr/local/src 77 | RUN git clone https://github.com/nils-ohlmeier/sipsak 78 | WORKDIR /usr/local/src/sipsak 79 | RUN autoreconf --install 80 | RUN ./configure 81 | RUN make 82 | RUN make install 83 | 84 | # RUN mkdir -p /usr/local/src/data/GeoLite2 85 | # RUN mkdir -p /usr/local/src/tmp 86 | # COPY GeoLite2-City.tar.gz /usr/local/src/tmp/GeoLite2-City.tar.gz 87 | # WORKDIR /usr/local/src/tmp 88 | # RUN tar xvfz GeoLite2-City.tar.gz 89 | # RUN mv GeoLite2-City_*/*.* ../data/GeoLite2/ 90 | # WORKDIR /usr/local/src 91 | # RUN rm -rf tmp 92 | 93 | COPY kamailio /usr/local/src/kamailio 94 | WORKDIR /usr/local/src/kamailio 95 | RUN git submodule update --init --remote misc/external/wolfssl/wolfssl 96 | RUN make RADCLI=1 exclude_modules="db_cassandra db_oracle dnssec ndb_cassandra nsq osp app_java rtp_media_server secsipid secsipid_proc stirshaken jwt nats ruxc microhttpd" cfg 97 | RUN make RADCLI=1 Q=0 CC_EXTRA_OPTS="-Wall" all 98 | RUN make RADCLI=1 install 99 | WORKDIR src/modules/tls 100 | RUN make install-tls-cert 101 | 102 | ENV DBENGINE=MYSQL 103 | ENV DBRWPW=kamailiorw 104 | ENV DBROOTPW=ktestsrootpw 105 | 106 | RUN pwd 107 | RUN ls -la /usr/local/src 108 | 109 | COPY kamailio-tests /usr/local/src/kamailio-tests 110 | COPY kamailio-tests/etc/excludeunits.txt.debian10 /usr/local/src/kamailio-tests/excludeunits.txt 111 | RUN ls -la /usr/local/src/kamailio-tests 112 | RUN ls -la /usr/local/src/kamailio-tests/units 113 | WORKDIR /usr/local/src/kamailio-tests 114 | 115 | ENTRYPOINT ["/usr/local/src/kamailio-tests/ktestsctl"] 116 | CMD ["-m", "run"] 117 | -------------------------------------------------------------------------------- /docker/Dockerfile.debian12: -------------------------------------------------------------------------------- 1 | FROM debian:bookworm 2 | 3 | RUN groupadd -r mysql && useradd -r -g mysql mysql 4 | 5 | RUN apt-get update 6 | 7 | RUN DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes apt-utils \ 8 | autoconf gcc g++ make procps \ 9 | coreutils exuberant-ctags curl gawk gdb git jq lynx netcat-traditional ngrep sed sip-tester vim wget \ 10 | bison libtool \ 11 | debhelper \ 12 | default-libmysqlclient-dev \ 13 | docbook-xml \ 14 | docbook2x \ 15 | dpkg-dev \ 16 | erlang-dev \ 17 | flex \ 18 | libbson-dev \ 19 | libconfuse-dev \ 20 | libcurl4-openssl-dev \ 21 | libdb-dev \ 22 | libev-dev \ 23 | libevent-dev \ 24 | libgcrypt20-dev \ 25 | libexpat1-dev \ 26 | libgeoip-dev \ 27 | libhiredis-dev \ 28 | libjansson-dev \ 29 | libjson-c-dev \ 30 | libldap2-dev \ 31 | liblua5.1-0-dev \ 32 | libmaxminddb-dev \ 33 | libmediastreamer-dev \ 34 | libmemcached-dev \ 35 | libmicrohttpd-dev \ 36 | libmnl-dev \ 37 | libmongoc-dev \ 38 | libmono-2.0-dev \ 39 | libmosquitto-dev \ 40 | libncurses5-dev \ 41 | libnghttp2-dev \ 42 | libortp-dev \ 43 | libpcre2-dev \ 44 | libperl-dev \ 45 | libphonenumber-dev \ 46 | libpq-dev \ 47 | librabbitmq-dev \ 48 | libradcli-dev \ 49 | libreadline-dev \ 50 | librdkafka-dev \ 51 | libsasl2-dev \ 52 | libsctp-dev \ 53 | libsnmp-dev \ 54 | libsqlite3-dev \ 55 | libssl-dev \ 56 | libsystemd-dev \ 57 | libunistring-dev \ 58 | libxml2-dev \ 59 | libwebsockets-dev \ 60 | lua-cjson \ 61 | openssl \ 62 | pkg-config \ 63 | python3 \ 64 | python3-dev \ 65 | ruby-dev \ 66 | unixodbc-dev \ 67 | uuid-dev \ 68 | xsltproc \ 69 | zlib1g-dev 70 | 71 | ENV MYSQL_ROOT_PASSWORD=ktestsrootpw 72 | RUN DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes default-mysql-client default-mysql-server 73 | RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \ 74 | && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ 75 | && chmod 777 /var/run/mysqld \ 76 | && find /etc/mysql/ -name '*.cnf' -print0 \ 77 | | xargs -0 grep -lZE '^(bind-address|log)' \ 78 | | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \ 79 | && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf 80 | RUN mysql_install_db --user=mysql 81 | 82 | WORKDIR /usr/local/src 83 | RUN git clone https://github.com/nils-ohlmeier/sipsak 84 | WORKDIR /usr/local/src/sipsak 85 | RUN autoreconf --install 86 | RUN ./configure 87 | RUN make 88 | RUN make install 89 | 90 | # RUN mkdir -p /usr/local/src/data/GeoLite2 91 | # RUN mkdir -p /usr/local/src/tmp 92 | # COPY GeoLite2-City.tar.gz /usr/local/src/tmp/GeoLite2-City.tar.gz 93 | # WORKDIR /usr/local/src/tmp 94 | # RUN tar xvfz GeoLite2-City.tar.gz 95 | # RUN mv GeoLite2-City_*/*.* ../data/GeoLite2/ 96 | # WORKDIR /usr/local/src 97 | # RUN rm -rf tmp 98 | 99 | COPY kamailio /usr/local/src/kamailio 100 | WORKDIR /usr/local/src/kamailio 101 | RUN git submodule update --init --remote misc/external/wolfssl/wolfssl 102 | RUN make RADCLI=1 exclude_modules="app_java app_python db_cassandra db_oracle dnssec jwt ndb_cassandra nats nsq osp ruxc secsipid secsipid_proc stirshaken" cfg 103 | RUN make RADCLI=1 Q=0 CC_EXTRA_OPTS="-Wall" all 104 | RUN make RADCLI=1 install 105 | WORKDIR src/modules/tls 106 | RUN make install-tls-cert 107 | 108 | ENV DBENGINE=MYSQL 109 | ENV DBRWPW=kamailiorw 110 | ENV DBROOTPW=ktestsrootpw 111 | 112 | RUN pwd 113 | RUN ls -la /usr/local/src 114 | 115 | COPY kamailio-tests /usr/local/src/kamailio-tests 116 | COPY kamailio-tests/etc/excludeunits.txt.debian10 /usr/local/src/kamailio-tests/excludeunits.txt 117 | RUN ls -la /usr/local/src/kamailio-tests 118 | RUN ls -la /usr/local/src/kamailio-tests/units 119 | WORKDIR /usr/local/src/kamailio-tests 120 | 121 | ENTRYPOINT ["/usr/local/src/kamailio-tests/ktestsctl"] 122 | CMD ["-m", "run"] 123 | -------------------------------------------------------------------------------- /docker/Dockerfile.debian9: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | 3 | RUN groupadd -r mysql && useradd -r -g mysql mysql 4 | 5 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes apt-utils \ 6 | autoconf gcc g++ make procps \ 7 | coreutils ctags curl gawk gdb git jq lynx netcat ngrep sed sip-tester vim wget \ 8 | bison \ 9 | debhelper \ 10 | default-libmysqlclient-dev \ 11 | dh-systemd \ 12 | docbook-xml \ 13 | docbook2x \ 14 | dpkg-dev \ 15 | erlang-dev \ 16 | flex \ 17 | gcj-jdk \ 18 | libbson-dev \ 19 | libconfuse-dev \ 20 | libcurl4-openssl-dev \ 21 | libdb-dev \ 22 | libev-dev \ 23 | libevent-dev \ 24 | libexpat1-dev \ 25 | libgeoip-dev \ 26 | libhiredis-dev \ 27 | libjansson-dev \ 28 | libjson-c-dev \ 29 | libldap2-dev \ 30 | liblua5.1-0-dev \ 31 | libmaxminddb-dev \ 32 | libmemcached-dev \ 33 | libmnl-dev \ 34 | libmongoc-dev \ 35 | libmono-2.0-dev \ 36 | libmosquitto-dev \ 37 | libncurses5-dev \ 38 | libpcre3-dev \ 39 | libperl-dev \ 40 | libphonenumber-dev \ 41 | libpq-dev \ 42 | librabbitmq-dev \ 43 | libradcli-dev \ 44 | libreadline-dev \ 45 | librdkafka-dev \ 46 | libsasl2-dev \ 47 | libsctp-dev \ 48 | libsnmp-dev \ 49 | libsqlite3-dev \ 50 | libssl-dev \ 51 | libsystemd-dev \ 52 | libunistring-dev \ 53 | libxml2-dev \ 54 | lua-cjson \ 55 | openssl \ 56 | pkg-config \ 57 | python \ 58 | python-dev \ 59 | python3-dev \ 60 | ruby-dev \ 61 | unixodbc-dev \ 62 | uuid-dev \ 63 | xsltproc \ 64 | zlib1g-dev 65 | 66 | ENV MYSQL_ROOT_PASSWORD=ktestsrootpw 67 | RUN DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes mysql-client mysql-server 68 | RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/run/mysqld \ 69 | && chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \ 70 | && chmod 777 /var/run/mysqld \ 71 | && find /etc/mysql/ -name '*.cnf' -print0 \ 72 | | xargs -0 grep -lZE '^(bind-address|log)' \ 73 | | xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/' \ 74 | && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf 75 | RUN mysql_install_db --user=mysql 76 | 77 | WORKDIR /usr/local/src 78 | RUN git clone -b 0.9.7 https://github.com/nils-ohlmeier/sipsak 79 | WORKDIR /usr/local/src/sipsak 80 | RUN autoreconf --install 81 | RUN ./configure 82 | RUN make 83 | RUN make install 84 | 85 | # RUN mkdir -p /usr/local/src/data/GeoLite2 86 | # RUN mkdir -p /usr/local/src/tmp 87 | # COPY GeoLite2-City.tar.gz /usr/local/src/tmp/GeoLite2-City.tar.gz 88 | # WORKDIR /usr/local/src/tmp 89 | # RUN tar xvfz GeoLite2-City.tar.gz 90 | # RUN mv GeoLite2-City_*/*.* ../data/GeoLite2/ 91 | # WORKDIR /usr/local/src 92 | # RUN rm -rf tmp 93 | 94 | COPY kamailio /usr/local/src/kamailio 95 | WORKDIR /usr/local/src/kamailio 96 | RUN make JAVA_HOME=/usr/lib/jvm/java-gcj RADCLI=1 exclude_modules="db_cassandra db_oracle dnssec ndb_cassandra nsq osp rtp_media_server secsipid microhttpd" cfg 97 | RUN make JAVA_HOME=/usr/lib/jvm/java-gcj RADCLI=1 Q=0 CC_EXTRA_OPTS="-Wall" all 98 | RUN make JAVA_HOME=/usr/lib/jvm/java-gcj RADCLI=1 install 99 | WORKDIR src/modules/tls 100 | RUN make install-tls-cert 101 | 102 | ENV DBENGINE=MYSQL 103 | ENV DBRWPW=kamailiorw 104 | ENV DBROOTPW=ktestsrootpw 105 | 106 | RUN pwd 107 | RUN ls -la /usr/local/src 108 | 109 | COPY kamailio-tests /usr/local/src/kamailio-tests 110 | COPY kamailio-tests/etc/excludeunits.txt.debian9 /usr/local/src/kamailio-tests/excludeunits.txt 111 | RUN ls -la /usr/local/src/kamailio-tests 112 | RUN ls -la /usr/local/src/kamailio-tests/units 113 | WORKDIR /usr/local/src/kamailio-tests 114 | 115 | ENTRYPOINT ["/usr/local/src/kamailio-tests/ktestsctl"] 116 | CMD ["-m", "run"] 117 | -------------------------------------------------------------------------------- /etc/config: -------------------------------------------------------------------------------- 1 | # config variables 2 | 3 | KAMBIN=${KAMBIN:-/usr/local/sbin/kamailio} 4 | KAMCTL=${KAMCTL:-/usr/local/sbin/kamctl} 5 | KAMCFG=${KAMCFG:-/usr/local/sbin/kamailio.cfg} 6 | KAMRUN=${KAMRUN:-/var/run/kamailio} 7 | KAMPID=${KAMPID:-${KAMRUN}/kamailio.pid} 8 | 9 | LOGFILE=/tmp/kamailio-tests.log 10 | 11 | UNITOUTPUT=${UNITOUTPUT:-yes} 12 | -------------------------------------------------------------------------------- /etc/excludeunits.txt.centos7: -------------------------------------------------------------------------------- 1 | tphonu0001 2 | tgeoip0001 3 | -------------------------------------------------------------------------------- /etc/excludeunits.txt.debian10: -------------------------------------------------------------------------------- 1 | tgeoip0001 2 | -------------------------------------------------------------------------------- /etc/excludeunits.txt.debian9: -------------------------------------------------------------------------------- 1 | tgeoip0001 2 | -------------------------------------------------------------------------------- /ktestsctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . etc/config 4 | 5 | ### version for this script 6 | VERSION='1.0.1' 7 | LOGDATE=`date` 8 | 9 | ### return non-zero code if at least one test failed 10 | TESTS_FAILED=0 11 | 12 | ktestsctl_usage() { 13 | cat < ..... run tests with a filter on unit names 26 | run ... run the test unit 27 | 28 | -- command 'help' -- 29 | help ............. print the help text 30 | 31 | -- command 'version' -- 32 | version .......... print the version string 33 | 34 | Version: $0 ${VERSION} 35 | 36 | EOF 37 | } 38 | 39 | ktestsctl_mysqld_alive() { 40 | mysqladmin -h localhost ping 41 | } 42 | 43 | # prepare mysql server 44 | ktestsctl_mysql() { 45 | echo "=== unit tests - prepare mysql server ===" 46 | 47 | if [ -f /etc/redhat-release ] ; then 48 | mysqld_safe & 49 | else 50 | /usr/sbin/mysqld --user=root & 51 | fi 52 | 53 | sleep 5 54 | count=0 55 | until ( ktestsctl_mysqld_alive ) 56 | do 57 | ((count++)) 58 | if [ ${count} -gt 50 ] 59 | then 60 | echo "error: mysqld did not become ready in time" 61 | exit 1 62 | fi 63 | sleep 0.1 64 | done 65 | sleep 1 66 | mysqladmin -u root password "${DBROOTPW}" 67 | INSTALL_EXTRA_TABLES=yes INSTALL_PRESENCE_TABLES=yes \ 68 | INSTALL_DBUID_TABLES=yes CHARSET="latin1" kamdbctl create 69 | } 70 | 71 | # execute one or more test units 72 | ktestsrun() { 73 | echo "=== unit tests execution start ===" 74 | echo "running test units at: ${LOGDATE}" >${LOGFILE} 75 | echo "" >>${LOGFILE} 76 | if [ $# -lt 1 ] ; then 77 | UNITSLIST=`find units/t* -maxdepth 1 -type d` 78 | else 79 | UNITSLIST=`find units/${1}* -maxdepth 1 -type d` 80 | fi 81 | for tdir in ${UNITSLIST} ; do 82 | if [[ ${tdir} =~ $(echo ^units\/\($(paste -sd'|' excludeunits.txt)\)$) ]]; then 83 | echo 84 | echo "Skipping ${tdir} as requested..." 85 | continue 86 | fi 87 | if [[ -d "${tdir}" && ! -L "${tdir}" ]]; then 88 | tname=`basename ${tdir}` 89 | texec="${tname}.sh" 90 | tpath="${tdir}/${texec}" 91 | 92 | if [[ -f "${tpath}" && -x "${tpath}" ]]; then 93 | echo 94 | tsummary="" 95 | if [[ -f "${tdir}/README.md" ]]; then 96 | tsummary=`grep "^Summary: " ${tdir}/README.md | cut -c10-` 97 | fi 98 | if [[ ! -z "${tsummary}" ]]; then 99 | echo "* test unit ${tname}: ${tsummary}" | tee -a ${LOGFILE} 100 | fi 101 | echo "test unit ${tname}: running ..." 102 | cd ${tdir} 103 | if [ "${UNITOUTPUT}" == "no" ]; then 104 | # save stdout and stderr, then redirect to /dev/null 105 | exec 3>&1 4>&2 >/dev/null 2>&1 106 | fi 107 | ./${texec} 108 | ret=$? 109 | if [ "${UNITOUTPUT}" == "no" ]; then 110 | # restore stdout and stderr 111 | exec 1>&3 2>&4 112 | fi 113 | cd ../.. 114 | if [ ! "$ret" -eq 0 ] ; then 115 | echo "- test unit ${tname}: failed" | tee -a ${LOGFILE} 116 | TESTS_FAILED=1 117 | else 118 | echo "- test unit ${tname}: ok" | tee -a ${LOGFILE} 119 | fi 120 | fi 121 | fi 122 | done 123 | sleep 1 124 | echo 125 | echo "=== unit tests execution report ===" 126 | echo 127 | cat ${LOGFILE} 128 | echo 129 | echo "=== unit tests execution end ===" 130 | echo 131 | } 132 | 133 | # 134 | ##### ================================================ ##### 135 | 136 | ### evaluate first the options 137 | CMDPARAMS=() 138 | KTESTSWAIT="no" 139 | while [[ $# -gt 0 ]] 140 | do 141 | key="$1" 142 | 143 | case $key in 144 | -m|--mysql) 145 | ktestsctl_mysql 146 | shift 147 | ;; 148 | -q|--quiet) 149 | UNITOUTPUT="no" 150 | shift 151 | ;; 152 | -w|--wait) 153 | KTESTSWAIT="yes" 154 | shift 155 | ;; 156 | *) 157 | CMDPARAMS+=("$1") 158 | shift 159 | ;; 160 | esac 161 | done 162 | 163 | set -- "${CMDPARAMS[@]}" # restore positional parameters 164 | 165 | ### main command switch 166 | # 167 | echo 168 | if [ -n "${KAMRUN}" ] ; then 169 | mkdir -p ${KAMRUN} 170 | chmod a+w ${KAMRUN} 171 | fi 172 | 173 | case $1 in 174 | run) 175 | if [ $# -lt 2 ] ; then 176 | ktestsrun 177 | else 178 | ktestsrun "${2}" 179 | fi 180 | if [ "${KTESTSWAIT}" == "yes" ]; then 181 | echo 182 | echo "=== waiting ..." 183 | echo "=== this option requires to use 'docker run -i ...''" 184 | echo "=== to exit: press any key and " 185 | read -rs -n 1 key 186 | fi 187 | exit $TESTS_FAILED 188 | ;; 189 | help) 190 | ktestsctl_usage 191 | exit 1 192 | ;; 193 | version) 194 | echo "$0 $VERSION" 195 | ;; 196 | *) 197 | ktestsctl_usage 198 | exit 1 199 | ;; 200 | esac 201 | -------------------------------------------------------------------------------- /libs/utils: -------------------------------------------------------------------------------- 1 | # common functions 2 | 3 | kill_kamailio() { 4 | killall kamailio 5 | } 6 | 7 | kill_pidfile() { 8 | kill $(cat ${1}) 9 | } -------------------------------------------------------------------------------- /units/tasync0001/README.md: -------------------------------------------------------------------------------- 1 | # Async Routing - Cfg Variables Tests # 2 | 3 | Summary: async routing - cfg variables tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tasync0001.cfg and test if variables are set 8 | in the request and async routes 9 | -------------------------------------------------------------------------------- /units/tasync0001/kamailio-tasync0001-inc.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | info.var_inc = 1 desc "Var from included file" 4 | -------------------------------------------------------------------------------- /units/tasync0001/kamailio-tasync0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | async_workers=1 5 | 6 | include_file "kamailio-tasync0001-inc.cfg" 7 | 8 | loadmodule "kex.so" 9 | loadmodule "jsonrpcs.so" 10 | loadmodule "tm.so" 11 | loadmodule "tmx.so" 12 | loadmodule "sl.so" 13 | loadmodule "rr.so" 14 | loadmodule "pv.so" 15 | loadmodule "async.so" 16 | loadmodule "xlog.so" 17 | 18 | modparam("jsonrpcs", "pretty_format", 1) 19 | 20 | info.var_loc = 1 desc "Info Variable" 21 | 22 | request_route { 23 | if(@cfg_get.info.var_loc == 1) { 24 | xlog("request_route: var_loc is 1\n"); 25 | } 26 | if(@cfg_get.info.var_inc == 1) { 27 | xlog("request_route: var_inc is 1\n"); 28 | } 29 | 30 | if(t_newtran()) { 31 | async_task_route("ASYNC_REQUEST_ROUTE"); 32 | } 33 | exit; 34 | } 35 | 36 | route[ASYNC_REQUEST_ROUTE] { 37 | if(@cfg_get.info.var_loc == 1) { 38 | xlog("async_route: var_loc is 1\n"); 39 | } else { 40 | $var(tmp) = @cfg_get.info.var_loc; 41 | xlog("async_route: var tmp is $var(tmp)\n"); 42 | } 43 | if(@cfg_get.info.var_inc == 1) { 44 | xlog("async_route: var_inc is 1\n"); 45 | } 46 | 47 | t_reply("200", "OK"); 48 | } -------------------------------------------------------------------------------- /units/tasync0001/tasync0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tasync0001.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tasync0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tasync0001.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -s sip:test@127.0.0.1 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | grep "request_route: var_loc is 1" /tmp/kamailio-tasync0001.log 18 | ret=$? 19 | if [ ! "$ret" -eq 0 ] ; then 20 | exit 1 21 | fi 22 | grep "request_route: var_inc is 1" /tmp/kamailio-tasync0001.log 23 | ret=$? 24 | if [ ! "$ret" -eq 0 ] ; then 25 | exit 1 26 | fi 27 | grep "async_route: var_loc is 1" /tmp/kamailio-tasync0001.log 28 | ret=$? 29 | if [ ! "$ret" -eq 0 ] ; then 30 | exit 1 31 | fi 32 | grep "async_route: var_inc is 1" /tmp/kamailio-tasync0001.log 33 | ret=$? 34 | if [ ! "$ret" -eq 0 ] ; then 35 | exit 1 36 | fi 37 | exit 0 38 | -------------------------------------------------------------------------------- /units/tauthx0001/README.md: -------------------------------------------------------------------------------- 1 | # User Authentication - Basic Tests # 2 | 3 | Summary: user authentication - basic tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tauth0001.cfg` and do user authentication 8 | using records from `subscriber` table of `kamailio` database in MySQL server, 9 | with and without multi-domain 10 | -------------------------------------------------------------------------------- /units/tauthx0001/kamailio-tauthx0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio" 6 | 7 | #!ifdef WITH_MULTIDOMAIN 8 | #!define MULTIDOMAIN 1 9 | #!else 10 | #!define MULTIDOMAIN 0 11 | #!endif 12 | 13 | loadmodule "db_mysql.so" 14 | loadmodule "jsonrpcs.so" 15 | loadmodule "kex.so" 16 | loadmodule "corex.so" 17 | loadmodule "tm.so" 18 | loadmodule "tmx.so" 19 | loadmodule "sl.so" 20 | loadmodule "pv.so" 21 | loadmodule "xlog.so" 22 | loadmodule "auth.so" 23 | loadmodule "auth_db.so" 24 | 25 | modparam("auth_db", "db_url", DBURL) 26 | modparam("auth_db", "calculate_ha1", yes) 27 | modparam("auth_db", "password_column", "password") 28 | modparam("auth_db", "load_credentials", "") 29 | modparam("auth_db", "use_domain", MULTIDOMAIN) 30 | 31 | request_route { 32 | if (!auth_check("$fd", "subscriber", "0")) { 33 | auth_challenge("$fd", "0"); 34 | exit; 35 | } 36 | 37 | xlog("user $au is authenticated\n"); 38 | sl_send_reply("200", "OK"); 39 | exit; 40 | } -------------------------------------------------------------------------------- /units/tauthx0001/tauthx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- run: ${KAMCTL} add alice@127.0.0.1 ..." 7 | ${KAMCTL} add alice@127.0.0.1 alice123 8 | ${KAMCTL} db show subscriber 9 | echo "--- start kamailio -f ./kamailio-tauthx0001.cfg" 10 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tauthx0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tauthx0001.log & 11 | ret=$? 12 | sleep 1 13 | sipsak -u alice -a alice123 -H 127.0.0.1 -c sip:alice@127.0.0.1 -s sip:bob@127.0.0.1 14 | sleep 1 15 | kill_pidfile ${KAMPID} 16 | sleep 1 17 | echo 18 | echo "--- grep output" 19 | echo 20 | grep "user alice is authenticated" /tmp/kamailio-tauthx0001.log 21 | ret=$? 22 | if [ ! "$ret" -eq 0 ] ; then 23 | exit 1 24 | fi 25 | echo "--- start kamailio -f ./kamailio-tauthx0001.cfg -A WITH_MULTIDOMAIN" 26 | rm -f /tmp/kamailio-tauthx0001.log 27 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tauthx0001.cfg -A WITH_MULTIDOMAIN -a no -ddd -E 2>&1 | tee /tmp/kamailio-tauthx0001.log & 28 | ret=$? 29 | sleep 1 30 | sipsak -u alice -a alice123 -H 127.0.0.1 -c sip:alice@127.0.0.1 -s sip:bob@127.0.0.1 31 | sleep 1 32 | kill_pidfile ${KAMPID} 33 | sleep 1 34 | echo 35 | echo "--- grep output" 36 | echo 37 | grep "user alice is authenticated" /tmp/kamailio-tauthx0001.log 38 | ret=$? 39 | if [ ! "$ret" -eq 0 ] ; then 40 | exit 1 41 | fi 42 | exit 0 -------------------------------------------------------------------------------- /units/tauthx0002/README.md: -------------------------------------------------------------------------------- 1 | # XKeys Authentication - Using KEMI Lua Script # 2 | 3 | Summary: xkeys authentication - using kemi lua script 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tauth0002.cfg` and do xkeys authentication 8 | using KEMI Lua script 9 | -------------------------------------------------------------------------------- /units/tauthx0002/kamailio-tauthx0002.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | debug=3 4 | children=2 5 | 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "kex.so" 8 | loadmodule "corex.so" 9 | loadmodule "sl.so" 10 | loadmodule "pv.so" 11 | loadmodule "kemix.so" 12 | loadmodule "auth_xkeys.so" 13 | loadmodule "app_lua.so" 14 | 15 | # ----- auth_xkeys params ----- 16 | modparam("auth_xkeys", "xkey", "id=kid1;name=key1;value=zbbmWVQ7mofEJ6yJHxuc") 17 | 18 | # ----- app_lua params ----- 19 | modparam("app_lua", "reload", 1) 20 | modparam("app_lua", "load", "kamailio-tauthx0002.lua") 21 | 22 | ####### Routing Logic ######## 23 | 24 | cfgengine "lua" 25 | -------------------------------------------------------------------------------- /units/tauthx0002/kamailio-tauthx0002.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- 3 | -- 4 | 5 | AUTH_XKEYS_TIMEFRAME=90 6 | 7 | -- SIP request routing 8 | -- equivalent of request_route{} 9 | function ksr_request_route() 10 | local timehdr = ""; 11 | -- from nodes with auth xkeys support 12 | if KSR.hdr.is_present("X-AuthXKeys-Token") > 0 13 | and KSR.hdr.is_present("X-AuthXKeys-Time") > 0 then 14 | timehdr = KSR.pv.gete("$hdr(X-AuthXKeys-Time)"); 15 | local tlimit = tonumber(timehdr); 16 | if tlimit ~= NILL and tlimit >= os.time() then 17 | if KSR.auth_xkeys.auth_xkeys_check("X-AuthXKeys-Token", "kid1", "sha256", 18 | timehdr .. ":" .. KSR.pv.gete("$hdr(CSeq)") .. ":" .. KSR.pv.gete("$ci") 19 | .. ":" .. KSR.pv.gete("$fu") .. ":" .. KSR.pv.gete("$ru")) > 0 then 20 | KSR.info("auth xkeys ok\n"); 21 | KSR.sl.sl_send_reply(200, "ok"); 22 | return 1; 23 | end 24 | end 25 | KSR.info("auth xkeys failed\n"); 26 | KSR.sl.sl_send_reply(403, "Not allowed"); 27 | return 1; 28 | end 29 | 30 | timehdr = tostring(os.time() + AUTH_XKEYS_TIMEFRAME); 31 | KSR.hdr.append("X-AuthXKeys-Time: " .. timehdr .. "\r\n"); 32 | KSR.auth_xkeys.auth_xkeys_add("X-AuthXKeys-Token", "kid1", "sha256", 33 | timehdr .. ":" .. KSR.pv.gete("$hdr(CSeq)") .. ":" .. KSR.pv.gete("$ci") 34 | .. ":" .. KSR.kx.get_furi() .. ":" .. KSR.kx.get_ruri()); 35 | KSR.setdsturi("sip:" .. KSR.pv.gete("$Ri") .. ":" .. KSR.pv.gete("$Rp")); 36 | KSR.forward(); 37 | return 1; 38 | end 39 | -------------------------------------------------------------------------------- /units/tauthx0002/tauthx0002.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tauthx0002.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w . -Y ${KAMRUN} -f ./kamailio-tauthx0002.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tauthx0002.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -H 127.0.0.1 -c sip:alice@127.0.0.1 -s sip:bob@127.0.0.1 -B "hello there" 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | grep "auth xkeys ok" /tmp/kamailio-tauthx0002.log 18 | ret=$? 19 | if [ ! "$ret" -eq 0 ] ; then 20 | exit 1 21 | fi 22 | exit 0 23 | -------------------------------------------------------------------------------- /units/tavpop0001/README.md: -------------------------------------------------------------------------------- 1 | # avpops - avp_subst() Tests # 2 | 3 | Summary: avpops - avp_subst() and avp_subst_pv() tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tavpop0001.cfg and test if avps are set 8 | accordingly with the subst rules 9 | -------------------------------------------------------------------------------- /units/tavpop0001/kamailio-tavpop0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=1 4 | 5 | loadmodule "kex.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "tm.so" 8 | loadmodule "tmx.so" 9 | loadmodule "sl.so" 10 | loadmodule "rr.so" 11 | loadmodule "pv.so" 12 | loadmodule "textops.so" 13 | loadmodule "avpops.so" 14 | loadmodule "xlog.so" 15 | 16 | modparam("jsonrpcs", "pretty_format", 1) 17 | 18 | request_route { 19 | if (!is_method("MESSAGE")) exit; 20 | 21 | $(avp(src)[*]) = "testME"; 22 | avp_subst("$avp(src)", "/test/xxxx/g"); 23 | $var(res) = "xxxxME"; 24 | route(CHECK); 25 | 26 | $(avp(src)[*]) = "testME"; 27 | $var(x) = "yyy"; 28 | avp_subst("$avp(src)", "/test/$var(x)/g"); 29 | $var(res) = "yyyME"; 30 | route(CHECK); 31 | 32 | $(avp(src)[*]) = "testME"; 33 | $var(x) = "/test/yyy/g"; 34 | avp_subst_pv("$avp(src)", "$var(x)"); 35 | route(CHECK); 36 | 37 | $(avp(src)[*]) = "testME"; 38 | avp_subst("$avp(src)", "/e/j/gi"); 39 | $var(res) = "tjstMj"; 40 | route(CHECK); 41 | 42 | $(avp(src)[*]) = "testME"; 43 | $var(x) = "j"; 44 | avp_subst("$avp(src)", "/e/$var(x)/gi"); 45 | route(CHECK); 46 | 47 | $(avp(src)[*]) = "testME"; 48 | $var(x) = "/e/j/gi"; 49 | avp_subst_pv("$avp(src)", "$var(x)"); 50 | route(CHECK); 51 | 52 | $(avp(src)[*]) = "testME"; 53 | $var(z) = "j"; 54 | $var(y) = "e"; 55 | $var(x) = "/" + $var(y) + "/" + $var(z) + "/gi"; 56 | avp_subst_pv("$avp(src)", "$var(x)"); 57 | route(CHECK); 58 | 59 | $(avp(src)[*]) = "testME"; 60 | $var(z) = "j"; 61 | $var(y) = "e"; 62 | avp_subst_pv("$avp(src)", "/$var(y)/$var(z)/gi"); 63 | route(CHECK); 64 | 65 | $(avp(src)[*]) = "testME"; 66 | $var(z) = "j"; 67 | $var(y) = "e"; 68 | avp_subst_pv("$avp(src)", "/" + $var(y) + "/" + $var(z) + "/gi"); 69 | route(CHECK); 70 | 71 | $(avp(src)[*]) = "testME"; 72 | avp_subst_pv("$avp(src)", "/e/j/gi"); 73 | route(CHECK); 74 | 75 | send_reply("200", "OK"); 76 | } 77 | 78 | route[CHECK] { 79 | if($avp(src) == $var(res)) { 80 | xlog("test$var(t): OK\n"); 81 | } else { 82 | xlog("test$var(t): $(avp(src)[*])\n"); 83 | } 84 | $var(t) = $var(t) + 1; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /units/tavpop0001/tavpop0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | LOG=/tmp/kamailio-tavpop0001.log 7 | 8 | echo "--- start kamailio -f ./kamailio-tavpop0001.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} \ 10 | -f ./kamailio-tavpop0001.cfg -a no -ddd -E 2>&1 | tee ${LOG} & 11 | sleep 1 12 | sipsak -M -s sip:test1test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | echo 17 | echo "--- grep output" 18 | echo 19 | for i in 0 1 2 3 4 5 6 7 8 9; do 20 | if ! grep -q "test${i}: OK" ${LOG}; then 21 | echo "test${i} failed" 22 | exit 1 23 | fi 24 | done 25 | exit 0 26 | -------------------------------------------------------------------------------- /units/tcfgxx0001/README.md: -------------------------------------------------------------------------------- 1 | # Default Config File - Basic Load Tests # 2 | 3 | Summary: default config file - basic load tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio -c 8 | * run kamailio with default config 9 | * run kamailio with default config and -A WITH_DEBUG 10 | -------------------------------------------------------------------------------- /units/tcfgxx0001/tcfgxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- run default config check" 7 | ${KAMBIN} -c 8 | ret=$? 9 | if [ ! "$ret" -eq 0 ] ; then 10 | exit $ret 11 | fi 12 | 13 | echo 14 | echo "--- start with default config" 15 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no 16 | ret=$? 17 | sleep 1 18 | kill_pidfile ${KAMPID} 19 | if [ ! "$ret" -eq 0 ] ; then 20 | exit $ret 21 | fi 22 | 23 | echo 24 | echo "--- start with default config and -A WITH_DEBUG" 25 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no -A WITH_DEBUG 26 | ret=$? 27 | sleep 1 28 | kill_pidfile ${KAMPID} 29 | if [ ! "$ret" -eq 0 ] ; then 30 | exit $ret 31 | fi 32 | 33 | echo 34 | echo "--- start with default config and main -A options (auth, ipauth, usrlodb)" 35 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no -E -e -A WITH_MYSQL -A WITH_IPAUTH -A WITH_USRLOCDB 36 | ret=$? 37 | sleep 1 38 | kill_pidfile ${KAMPID} 39 | if [ ! "$ret" -eq 0 ] ; then 40 | exit $ret 41 | fi 42 | 43 | echo 44 | echo "--- start with default config and all non-debug -A options (auth, ipauth, usrlodb, nat, presence ..." 45 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no -E -e -A WITH_MYSQL \ 46 | -A WITH_AUTH \ 47 | -A WITH_IPAUTH \ 48 | -A WITH_USRLOCDB \ 49 | -A WITH_PRESENCE \ 50 | -A WITH_NAT \ 51 | -A WITH_PSTN \ 52 | -A WITH_ALIASDB \ 53 | -A WITH_SPEEDDIAL \ 54 | -A WITH_MULTIDOMAIN \ 55 | -A WITH_TLS \ 56 | -A WITH_XMLRPC \ 57 | -A WITH_ANTIFLOOD \ 58 | -A WITH_BLOCK3XX \ 59 | -A WITH_BLOCK401407 \ 60 | -A WITH_VOICEMAIL \ 61 | -A WITH_ACCDB 62 | ret=$? 63 | sleep 1 64 | kill_pidfile ${KAMPID} 65 | if [ ! "$ret" -eq 0 ] ; then 66 | exit $ret 67 | fi 68 | 69 | exit $ret 70 | -------------------------------------------------------------------------------- /units/tcfgxx0002/README.md: -------------------------------------------------------------------------------- 1 | # Default Config File - Basic SIP Signaling Tests # 2 | 3 | Summary: default config file - basic sip signaling tests 4 | 5 | Following tests are done: 6 | 7 | * load with default config file and sent OPTIONS with sipsak to sip:127.0.0.1 -------------------------------------------------------------------------------- /units/tcfgxx0002/tcfgxx0002.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no 7 | ret=$? 8 | sleep 1 9 | if [ ! "$ret" -eq 0 ] ; then 10 | exit $ret 11 | fi 12 | sipsak -v -s sip:127.0.0.1 13 | ret=$? 14 | kill_pidfile ${KAMPID} 15 | 16 | exit $ret 17 | -------------------------------------------------------------------------------- /units/tcfgxx0003/README.md: -------------------------------------------------------------------------------- 1 | # faulty config - ifdef check Tests # 2 | 3 | Summary: faulty config - ifdef check Tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio -c with a faulty config 8 | -------------------------------------------------------------------------------- /units/tcfgxx0003/kamailio-tcfgxx0003.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | #!define WITH_ME 4 | 5 | request_route { 6 | drop; 7 | } 8 | 9 | #!ifndef WITH_ME 10 | request[ME] { 11 | exit; 12 | } 13 | -------------------------------------------------------------------------------- /units/tcfgxx0003/tcfgxx0003.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | LOG=/tmp/kamailio-tcfgxx0003.log 7 | 8 | function check_out() { 9 | if ! grep -q 'different number of preprocessor directives' ${LOG} ; then 10 | echo "'different number of preprocessor directives' not found on check" 11 | exit 1 12 | fi 13 | echo > ${LOG} 14 | } 15 | 16 | echo "--- run config check" 17 | ${KAMBIN} -c -f ./kamailio-tcfgxx0003.cfg >/dev/null 2>&1 18 | ret=$? 19 | if [ "$ret" -eq 0 ] ; then 20 | echo "kamailio didn't fail" 21 | exit 1 22 | fi 23 | ${KAMBIN} -c -f ./kamailio-tcfgxx0003.cfg 2>&1 | tee ${LOG} 24 | check_out 25 | 26 | echo 27 | echo "--- start kamailio -f ./kamailio-tcfgxx0003.cfg" 28 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no -ddd -E \ 29 | -f ./kamailio-tcfgxx0003.cfg >/dev/null 2>&1 30 | ret=$? 31 | if [ "$ret" -eq 0 ] ; then 32 | sleep 1 33 | kill_pidfile ${KAMPID} 34 | echo "kamailio didn't fail" 35 | exit 1 36 | fi 37 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no -ddd -E \ 38 | -f ./kamailio-tcfgxx0003.cfg 2>&1 | tee ${LOG} 39 | check_out 40 | 41 | exit 0 42 | -------------------------------------------------------------------------------- /units/tgeoip0001/README.md: -------------------------------------------------------------------------------- 1 | # Geoip2 Module - Basic Tests # 2 | 3 | Summary: geoip2 module - basic tests 4 | 5 | Following tests are done: 6 | 7 | * load geoip2 module and test the country for ip 8.8.8.8 8 | -------------------------------------------------------------------------------- /units/tgeoip0001/kamailio-tgeoip0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | loadmodule "db_mysql.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "kex.so" 8 | loadmodule "corex.so" 9 | loadmodule "tm.so" 10 | loadmodule "tmx.so" 11 | loadmodule "sl.so" 12 | loadmodule "pv.so" 13 | loadmodule "xlog.so" 14 | loadmodule "geoip2.so" 15 | 16 | modparam("geoip2", "path", "/usr/local/src/data/GeoLite2/GeoLite2-City.mmdb") 17 | 18 | request_route { 19 | if(geoip2_match("8.8.8.8", "src")) { 20 | xlog("ip address is registered in $gip2(src=>cc)\n"); 21 | } else { 22 | xlog("geoip match failure\n"); 23 | } 24 | sl_send_reply("200", "OK"); 25 | exit; 26 | } 27 | -------------------------------------------------------------------------------- /units/tgeoip0001/tgeoip0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tgeoip0001.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tgeoip0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tgeoip0001.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -s sip:alice@127.0.0.1 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | grep "ip address is registered in US" /tmp/kamailio-tgeoip0001.log 18 | ret=$? 19 | rm -f /tmp/kamailio-tgeoip0001.log 20 | if [ ! "$ret" -eq 0 ] ; then 21 | exit 1 22 | fi 23 | exit 0 24 | -------------------------------------------------------------------------------- /units/tgroup0001/README.md: -------------------------------------------------------------------------------- 1 | # Group Module - Group Membership Tests # 2 | 3 | Summary: group module - group membership tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tgroup0001.cfg and test if user alice is member 8 | or not of the group test 9 | -------------------------------------------------------------------------------- /units/tgroup0001/kamailio-tgroup0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio" 6 | 7 | #!ifdef WITH_MULTIDOMAIN 8 | #!define MULTIDOMAIN 1 9 | #!else 10 | #!define MULTIDOMAIN 0 11 | #!endif 12 | 13 | loadmodule "db_mysql.so" 14 | loadmodule "jsonrpcs.so" 15 | loadmodule "kex.so" 16 | loadmodule "corex.so" 17 | loadmodule "tm.so" 18 | loadmodule "tmx.so" 19 | loadmodule "sl.so" 20 | loadmodule "pv.so" 21 | loadmodule "xlog.so" 22 | loadmodule "group.so" 23 | 24 | modparam("group", "db_url", DBURL) 25 | modparam("group", "use_domain", MULTIDOMAIN) 26 | 27 | request_route { 28 | if(is_user_in("Request-URI", "test")) { 29 | xlog("user $rU is in group test\n"); 30 | sl_send_reply("200", "OK"); 31 | exit; 32 | } 33 | xlog("user $rU is not in group test\n"); 34 | sl_send_reply("404", "Not found"); 35 | exit; 36 | } -------------------------------------------------------------------------------- /units/tgroup0001/tgroup0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | kill_kamailio 7 | sleep 1 8 | echo "--- run: VERIFY_ACL=0 VERIFY_USER=0 ${KAMCTL} acl grant alice@127.0.0.1 test" 9 | VERIFY_ACL=0 VERIFY_USER=0 ${KAMCTL} acl grant alice@127.0.0.1 test 10 | echo "--- start kamailio -f ./kamailio-tgroup0001.cfg" 11 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tgroup0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tgroup0001.log & 12 | ret=$? 13 | sleep 1 14 | sipsak -s sip:alice@127.0.0.1 15 | sleep 1 16 | kill_pidfile ${KAMPID} 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "user alice is in group test" /tmp/kamailio-tgroup0001.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | echo "--- start kamailio -f ./kamailio-tgroup0001.cfg -A WITH_MULTIDOMAIN" 27 | rm -f /tmp/kamailio-tgroup0001.log 28 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tgroup0001.cfg -A WITH_MULTIDOMAIN -a no -ddd -E 2>&1 | tee /tmp/kamailio-tgroup0001.log & 29 | ret=$? 30 | sleep 1 31 | sipsak -s sip:alice@127.0.0.1 32 | sleep 1 33 | kill_pidfile ${KAMPID} 34 | sleep 1 35 | echo 36 | echo "--- grep output" 37 | echo 38 | grep "user alice is in group test" /tmp/kamailio-tgroup0001.log 39 | ret=$? 40 | if [ ! "$ret" -eq 0 ] ; then 41 | exit 1 42 | fi 43 | exit 0 -------------------------------------------------------------------------------- /units/thacxx0001/README.md: -------------------------------------------------------------------------------- 1 | # http_aysnc_client - GET request # 2 | 3 | Summary: http_async_client - GET request 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thacxx0001.cfg and test if HTTP GET receives a 200 8 | 9 | -------------------------------------------------------------------------------- /units/thacxx0001/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_GET(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thacxx0001/kamailio-thacxx0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "http_async_client.so" 11 | 12 | debug=2 13 | children=2 14 | 15 | request_route { 16 | t_newtran(); 17 | # GET 18 | http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY"); 19 | } 20 | 21 | route[HTTP_REPLY] { 22 | if ($http_ok) { 23 | xlog("L_INFO", "HTTP GET REPLY: $http_rs - Response: $http_rb\n"); 24 | sl_send_reply("200", "OK"); 25 | exit; 26 | } 27 | else { 28 | xlog("L_ERR", "HTTP error: $http_err\n"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /units/thacxx0001/thacxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thacxx0001.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thacxx0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-thacxx0001.log & 10 | ret=$? 11 | sleep 1 12 | sipsak -s sip:test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | killall python3 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "HTTP GET REPLY: 200" /tmp/kamailio-thacxx0001.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/thacxx0002/README.md: -------------------------------------------------------------------------------- 1 | # http_aysnc_client - POST request # 2 | 3 | Summary: http_async_client - POST request 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thacxx0002.cfg and test if HTTP POST receives a 200 8 | 9 | -------------------------------------------------------------------------------- /units/thacxx0002/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_POST(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thacxx0002/kamailio-thacxx0002.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "http_async_client.so" 11 | 12 | debug=2 13 | children=2 14 | 15 | request_route { 16 | t_newtran(); 17 | $var(token) = "XYZ"; 18 | $http_req(body) = $_s({"city": "cagliari", "region": "sardinia"}); 19 | $http_req(hdr) = "Content-type: application/json"; 20 | $http_req(hdr) = "Authorization: Bearer " + $var(token); 21 | # POST 22 | http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY"); 23 | } 24 | 25 | route[HTTP_REPLY] { 26 | if ($http_ok) { 27 | xlog("L_INFO", "HTTP POST REPLY: $http_rs - Response: $http_rb\n"); 28 | sl_send_reply("200", "OK"); 29 | exit; 30 | } 31 | else { 32 | xlog("L_ERR", "HTTP error: $http_err\n"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /units/thacxx0002/thacxx0002.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thacxx0002.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thacxx0002.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-thacxx0002.log & 10 | ret=$? 11 | sleep 1 12 | sipsak -s sip:test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | killall python3 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "HTTP POST REPLY: 200" /tmp/kamailio-thacxx0002.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/thacxx0003/README.md: -------------------------------------------------------------------------------- 1 | # http_aysnc_client - DELETE request # 2 | 3 | Summary: http_async_client - DELETE request 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thacxx0003.cfg and test if HTTP DELETE receives a 200 8 | 9 | -------------------------------------------------------------------------------- /units/thacxx0003/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_DELETE(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thacxx0003/kamailio-thacxx0003.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "http_async_client.so" 11 | 12 | debug=2 13 | children=2 14 | 15 | request_route { 16 | t_newtran(); 17 | $var(id) = "123"; 18 | $var(token) = "XYZ"; 19 | # DELETE 20 | $http_req(method) = "DELETE"; 21 | $http_req(hdr) = "Authorization: Bearer " + $var(token); 22 | http_async_query("http://127.0.0.1:8080/$var(id)", "HTTP_REPLY"); 23 | } 24 | 25 | route[HTTP_REPLY] { 26 | if ($http_ok) { 27 | xlog("L_INFO", "HTTP DELETE REPLY: $http_rs - Response: $http_rb\n"); 28 | sl_send_reply("200", "OK"); 29 | exit; 30 | } 31 | else { 32 | xlog("L_ERR", "HTTP error: $http_err\n"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /units/thacxx0003/thacxx0003.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thacxx0003.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thacxx0003.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-thacxx0003.log & 10 | ret=$? 11 | sleep 1 12 | sipsak -s sip:test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | killall python3 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "HTTP DELETE REPLY: 200" /tmp/kamailio-thacxx0003.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/thacxx0004/README.md: -------------------------------------------------------------------------------- 1 | # http_aysnc_client - POST request synchronous # 2 | 3 | Summary: http_async_client - POST request synchronous 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thacxx0004.cfg and test if synchronous HTTP POST receives a 200 8 | 9 | -------------------------------------------------------------------------------- /units/thacxx0004/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_POST(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thacxx0004/kamailio-thacxx0004.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "http_async_client.so" 11 | 12 | debug=2 13 | children=2 14 | 15 | request_route { 16 | $var(token) = "XYZ"; 17 | $http_req(body) = $_s({"city": "cagliari", "region": "sardinia"}); 18 | $http_req(hdr) = "Content-type: application/json"; 19 | $http_req(hdr) = "Authorization: Bearer " + $var(token); 20 | 21 | $http_req(suspend) = 0; 22 | # synchrounous POST 23 | $var(result) = http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY"); 24 | 25 | if ($var(result) == 1) { 26 | sl_send_reply("200", "OK"); 27 | exit; 28 | } 29 | } 30 | 31 | route[HTTP_REPLY] { 32 | if ($http_ok) { 33 | xlog("L_INFO", "HTTP POST REPLY: $http_rs - Response: $http_rb\n"); 34 | } 35 | else { 36 | xlog("L_ERR", "HTTP error: $http_err\n"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /units/thacxx0004/thacxx0004.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thacxx0004.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thacxx0004.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-thacxx0004.log & 10 | ret=$? 11 | sleep 1 12 | sipsak -s sip:test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | killall python3 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "HTTP POST REPLY: 200" /tmp/kamailio-thacxx0004.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/thacxx0005/README.md: -------------------------------------------------------------------------------- 1 | # http_aysnc_client - Re-suspend reply # 2 | 3 | Summary: http_async_client - Re-suspend reply 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thacxx0005.cfg and test if re-suspending a reply to perform another HTTP query works 8 | 9 | -------------------------------------------------------------------------------- /units/thacxx0005/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_GET(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thacxx0005/kamailio-thacxx0005.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "siputils.so" 11 | loadmodule "textops.so" 12 | loadmodule "http_async_client.so" 13 | 14 | modparam("http_async_client", "workers", 4); 15 | 16 | debug=2 17 | children=4 18 | 19 | request_route { 20 | if (is_request()) { 21 | if (is_method("INVITE")) { 22 | xlog("L_INFO", "[$ci]================ INVITE_REQUEST ==================\n"); 23 | t_newtran(); 24 | t_on_reply("INVITE_REPLY"); 25 | t_relay("127.0.0.1", "5080"); 26 | exit; 27 | } 28 | else if (is_method("ACK")) { 29 | xlog("L_INFO", "[$ci]================ ACK_REQUEST ==================\n"); 30 | t_relay("127.0.0.1", "5080"); 31 | exit; 32 | } 33 | } 34 | drop; 35 | } 36 | 37 | reply_route { 38 | xlog("L_INFO", "[$ci]================ SIP_REPLY ==================\n"); 39 | } 40 | 41 | onreply_route[INVITE_REPLY] { 42 | xlog("L_INFO", "[$ci]================ INVITE_REPLY ==================\n"); 43 | if (status=~"200") { 44 | http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY1"); 45 | } 46 | } 47 | 48 | route[HTTP_REPLY1] { 49 | xlog("L_INFO", "[$ci]================ HTTP_REPLY1 ==================\n"); 50 | if ($http_ok) { 51 | xlog("L_INFO", "HTTP GET REPLY1: $http_rs - Response: $http_rb\n"); 52 | http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY2"); 53 | } 54 | else { 55 | xlog("L_ERR", "HTTP error: $http_err\n"); 56 | } 57 | } 58 | 59 | route[HTTP_REPLY2] { 60 | xlog("L_INFO", "[$ci]================ HTTP_REPLY2 ================== DONE\n"); 61 | } 62 | -------------------------------------------------------------------------------- /units/thacxx0005/thacxx0005.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thacxx0005.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thacxx0005.cfg -a no -dd -E 2>&1 | tee /tmp/kamailio-thacxx0005.log & 10 | ret=$? 11 | 12 | sleep 3 13 | 14 | echo "-------------- starting sipp UAS -------------------------" 15 | sipp -sf uas.xml -p 5080 -bg 16 | 17 | sleep 1 18 | 19 | NCALLS=20 20 | echo "-------------- starting sipp UAC -------------------------" 21 | sipp -sf uac.xml -m ${NCALLS} 127.0.0.1:5060 22 | 23 | kill_pidfile ${KAMPID} 24 | sleep 1 25 | killall python3 26 | sleep 1 27 | killall sipp 28 | 29 | echo 30 | count="$(grep -c "HTTP_REPLY2" /tmp/kamailio-thacxx0005.log)" 31 | if [ ! $count -eq $NCALLS ] ; then 32 | exit 1 33 | fi 34 | exit 0 35 | -------------------------------------------------------------------------------- /units/thacxx0005/uac.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ;tag=[call_number] 8 | To: sut 9 | Call-ID: [call_id] 10 | Cseq: 1 INVITE 11 | Contact: sip:sipp@[local_ip]:[local_port] 12 | Content-Type: application/sdp 13 | Content-Length: [len] 14 | 15 | v=0 16 | o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] 17 | s=- 18 | t=0 0 19 | c=IN IP[media_ip_type] [media_ip] 20 | m=audio [media_port] RTP/AVP 0 21 | a=rtpmap:0 PCMU/8000 22 | ]]> 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | ;tag=[call_number] 39 | To: sut [peer_tag_param] 40 | Call-ID: [call_id] 41 | Cseq: 1 ACK 42 | Contact: sip:sipp@[local_ip]:[local_port] 43 | Content-Length: 0 44 | ]]> 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /units/thacxx0005/uas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 17 | Content-Type: application/sdp 18 | Content-Length: [len] 19 | 20 | v=0 21 | o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] 22 | s=- 23 | c=IN IP[media_ip_type] [media_ip] 24 | t=0 0 25 | m=audio [media_port] RTP/AVP 0 26 | a=rtpmap:0 PCMU/8000 27 | ]]> 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /units/thacxx0006/README.md: -------------------------------------------------------------------------------- 1 | # http_aysnc_client - Re-suspend request # 2 | 3 | Summary: http_async_client - Re-suspend request 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thacxx0006.cfg and test if suspending a request twice to perform async HTTP requests works 8 | 9 | -------------------------------------------------------------------------------- /units/thacxx0006/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_GET(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thacxx0006/kamailio-thacxx0006.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "siputils.so" 11 | loadmodule "textops.so" 12 | loadmodule "http_async_client.so" 13 | 14 | modparam("http_async_client", "workers", 4); 15 | 16 | debug=2 17 | children=4 18 | 19 | request_route { 20 | if (is_request()) { 21 | if (is_method("INVITE")) { 22 | t_newtran(); 23 | http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY1"); 24 | } 25 | else if (is_method("ACK")) { 26 | t_relay("127.0.0.1", "5080"); 27 | exit; 28 | } 29 | } 30 | drop; 31 | } 32 | 33 | route[HTTP_REPLY1] { 34 | xlog("L_INFO", "[$ci]================ HTTP_REPLY1 ==================\n"); 35 | if ($http_ok) { 36 | xlog("L_INFO", "HTTP GET REPLY1: $http_rs - Response: $http_rb\n"); 37 | http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY2"); 38 | } 39 | else { 40 | xlog("L_ERR", "HTTP error: $http_err\n"); 41 | } 42 | } 43 | 44 | route[HTTP_REPLY2] { 45 | xlog("L_INFO", "[$ci]================ HTTP_REPLY2 ================== DONE\n"); 46 | t_on_reply("INVITE_REPLY"); 47 | t_relay("127.0.0.1", "5080"); 48 | exit; 49 | } 50 | 51 | onreply_route[INVITE_REPLY] { 52 | if (status=~"200") { 53 | xlog("L_INFO", "[$ci]============== INVITE_REPLY OK ================\n"); 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /units/thacxx0006/thacxx0006.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thacxx0006.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thacxx0006.cfg -a no -dd -E 2>&1 | tee /tmp/kamailio-thacxx0006.log & 10 | ret=$? 11 | 12 | sleep 3 13 | 14 | echo "-------------- starting sipp UAS -------------------------" 15 | sipp -sf uas.xml -p 5080 -bg 16 | 17 | sleep 1 18 | 19 | NCALLS=20 20 | echo "-------------- starting sipp UAC -------------------------" 21 | sipp -sf uac.xml -m ${NCALLS} 127.0.0.1:5060 22 | 23 | kill_pidfile ${KAMPID} 24 | sleep 1 25 | killall python3 26 | sleep 1 27 | killall sipp 28 | 29 | echo 30 | count="$(grep -c "INVITE_REPLY OK" /tmp/kamailio-thacxx0006.log)" 31 | if [ ! $count -eq $NCALLS ] ; then 32 | exit 1 33 | fi 34 | exit 0 35 | -------------------------------------------------------------------------------- /units/thacxx0006/uac.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ;tag=[call_number] 8 | To: sut 9 | Call-ID: [call_id] 10 | Cseq: 1 INVITE 11 | Contact: sip:sipp@[local_ip]:[local_port] 12 | Content-Type: application/sdp 13 | Content-Length: [len] 14 | 15 | v=0 16 | o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] 17 | s=- 18 | t=0 0 19 | c=IN IP[media_ip_type] [media_ip] 20 | m=audio [media_port] RTP/AVP 0 21 | a=rtpmap:0 PCMU/8000 22 | ]]> 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | ;tag=[call_number] 39 | To: sut [peer_tag_param] 40 | Call-ID: [call_id] 41 | Cseq: 1 ACK 42 | Contact: sip:sipp@[local_ip]:[local_port] 43 | Content-Length: 0 44 | ]]> 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /units/thacxx0006/uas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 17 | Content-Type: application/sdp 18 | Content-Length: [len] 19 | 20 | v=0 21 | o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] 22 | s=- 23 | c=IN IP[media_ip_type] [media_ip] 24 | t=0 0 25 | m=audio [media_port] RTP/AVP 0 26 | a=rtpmap:0 PCMU/8000 27 | ]]> 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /units/thttpc0001/README.md: -------------------------------------------------------------------------------- 1 | # http_client - GET request # 2 | 3 | Summary: http_client - GET request 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thttpc0001.cfg and test if HTTP GET receives a 200 8 | 9 | -------------------------------------------------------------------------------- /units/thttpc0001/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_GET(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thttpc0001/kamailio-thttpc0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "http_client.so" 11 | 12 | debug=2 13 | children=2 14 | 15 | request_route { 16 | $var(auth_token) = "XYZ"; 17 | 18 | # GET 19 | $var(result) = http_client_query("http://127.0.0.1:8080", "", "Authorization: Bearer $var(auth_token)", "$var(response)"); 20 | 21 | xlog("L_INFO", "HTTP GET REPLY: $var(result) - Response: $var(response)\n"); 22 | sl_send_reply("200", "OK"); 23 | exit; 24 | } 25 | -------------------------------------------------------------------------------- /units/thttpc0001/thttpc0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thttpc0001.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thttpc0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-thttpc0001.log & 10 | ret=$? 11 | sleep 1 12 | sipsak -s sip:test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | killall python3 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "HTTP GET REPLY: 200" /tmp/kamailio-thttpc0001.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/thttpc0002/README.md: -------------------------------------------------------------------------------- 1 | # http_client - POST request # 2 | 3 | Summary: http_client - POST request 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-thttpc0002.cfg and test if HTTP POST receives a 200 8 | 9 | -------------------------------------------------------------------------------- /units/thttpc0002/http_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from http.server import BaseHTTPRequestHandler, HTTPServer 3 | 4 | class HTTPHandler(BaseHTTPRequestHandler): 5 | def _set_response(self): 6 | self.send_response(200) 7 | self.send_header('Content-type', 'text/html') 8 | self.end_headers() 9 | 10 | def do_POST(self): 11 | self._set_response() 12 | 13 | def run(server_class=HTTPServer, handler_class=HTTPHandler, port=8080): 14 | server_address = ('', port) 15 | httpd = server_class(server_address, handler_class) 16 | try: 17 | httpd.serve_forever() 18 | except KeyboardInterrupt: 19 | pass 20 | httpd.server_close() 21 | 22 | if __name__ == '__main__': 23 | run() 24 | -------------------------------------------------------------------------------- /units/thttpc0002/kamailio-thttpc0002.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "kex.so" 4 | loadmodule "tm.so" 5 | loadmodule "tmx.so" 6 | loadmodule "sl.so" 7 | loadmodule "rr.so" 8 | loadmodule "pv.so" 9 | loadmodule "xlog.so" 10 | loadmodule "http_client.so" 11 | 12 | debug=2 13 | children=2 14 | 15 | request_route { 16 | $var(auth_token) = "XYZ"; 17 | 18 | # Some payload 19 | $var(payload) = $_s({"city": "cagliari", "region": "sardinia"}); 20 | 21 | # POST 22 | $var(result) = http_client_query("http://127.0.0.1:8080", "$var(payload)", "Content-type:application/json\r\nAuthorization: Bearer $var(auth_token)", "$var(response)"); 23 | 24 | xlog("L_INFO", "HTTP POST REPLY: $var(result) - Response: $var(response)\n"); 25 | sl_send_reply("200", "OK"); 26 | exit; 27 | } 28 | -------------------------------------------------------------------------------- /units/thttpc0002/thttpc0002.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | python3 http_server.py & 7 | 8 | echo "--- start kamailio -f ./kamailio-thttpc0002.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-thttpc0002.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-thttpc0002.log & 10 | ret=$? 11 | sleep 1 12 | sipsak -s sip:test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | killall python3 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "HTTP POST REPLY: 200" /tmp/kamailio-thttpc0002.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/tlcust0001/README.md: -------------------------------------------------------------------------------- 1 | # LOG_CUSTOM - Basic Tests # 2 | 3 | Summary: log_custom - basic tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tlcust0001.cfg` and do tests with sample SIP 8 | traffic 9 | -------------------------------------------------------------------------------- /units/tlcust0001/kamailio-tlcust0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | ####### Global Parameters ######### 4 | 5 | ### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR 6 | debug=2 7 | log_stderror=no 8 | 9 | memdbg=5 10 | memlog=5 11 | 12 | log_facility=LOG_LOCAL0 13 | log_prefix="{$mt $hdr(CSeq) $ci} " 14 | 15 | /* number of SIP routing processes */ 16 | children=2 17 | 18 | listen=udp:127.0.0.1:5060 19 | 20 | log_engine_type="udp" 21 | log_engine_data="127.0.0.1:24680" 22 | 23 | ####### Modules Section ######## 24 | 25 | /* set paths to location of modules */ 26 | # mpath="/usr/local/lib/kamailio/modules/" 27 | 28 | loadmodule "log_custom.so" 29 | loadmodule "jsonrpcs.so" 30 | loadmodule "kex.so" 31 | loadmodule "corex.so" 32 | loadmodule "tm.so" 33 | loadmodule "tmx.so" 34 | loadmodule "sl.so" 35 | loadmodule "rr.so" 36 | loadmodule "pv.so" 37 | loadmodule "maxfwd.so" 38 | loadmodule "textops.so" 39 | loadmodule "siputils.so" 40 | loadmodule "xlog.so" 41 | loadmodule "sanity.so" 42 | loadmodule "ctl.so" 43 | loadmodule "cfg_rpc.so" 44 | loadmodule "counters.so" 45 | 46 | 47 | ####### Routing Logic ######## 48 | 49 | 50 | /* Main SIP request routing logic 51 | * - processing of any incoming SIP request starts with this route 52 | * - note: this is the same as route { ... } */ 53 | request_route { 54 | xlog("===== xlog message - R-URI is $ru\n"); 55 | log_udp("===== logcustom message - R-URI is $ru\n"); 56 | sl_send_reply("200", "Received"); 57 | exit; 58 | } 59 | -------------------------------------------------------------------------------- /units/tlcust0001/tlcust0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | 7 | echo "--- start nc -u -l -p 24680 | tee /tmp/kamailio-tlcust0001.netcat &" 8 | rm -f /tmp/kamailio-tlcust0001.netcat 9 | nc -u -l -p 24680 | tee /tmp/kamailio-tlcust0001.netcat & 10 | sleep 1 11 | echo "--- start kamailio -f ./kamailio-tlcust0001.cfg" 12 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tlcust0001.cfg -a no 2>&1 | tee /tmp/kamailio-tlcust0001.log & 13 | ret=$? 14 | sleep 2 15 | echo "--- run sipsak -s sip:alice@127.0.0.1" 16 | sipsak -vvv -s sip:alice@127.0.0.1:5060 17 | sleep 1 18 | kill_pidfile ${KAMPID} 19 | sleep 1 20 | killall nc 21 | sleep 1 22 | echo 23 | echo "--- output files" 24 | echo 25 | ls -l /tmp 26 | echo "--- /tmp/kamailio-tlcust0001.netcat" 27 | cat /tmp/kamailio-tlcust0001.netcat 28 | echo "--- /tmp/kamailio-tlcust0001.log" 29 | cat /tmp/kamailio-tlcust0001.log 30 | echo "---" 31 | echo "--- grep output" 32 | grep "logcustom" /tmp/kamailio-tlcust0001.netcat 33 | ret=$? 34 | if [ ! "$ret" -eq 0 ] ; then 35 | exit 1 36 | fi 37 | exit 0 38 | -------------------------------------------------------------------------------- /units/tmodxx0001/README.md: -------------------------------------------------------------------------------- 1 | # Load All Modules - Detect Undefined Symbols # 2 | 3 | Summary: load all modules - detect undefined symbols 4 | 5 | All modules that compile on the guest OS and don't have init constraints are loaded, 6 | the rest are commented, see `kamailio-allmods.cfg`. Some modules have load conflicts 7 | because they define same variables (e.g., $rtpstat is defined by rtpengine and rtpproxy). 8 | 9 | Following tests are done: 10 | 11 | * run `kamailio -f kamailio-allmods.cfg` 12 | * run `kamailio -f kamailio-allmods.cfg -A WITH_IMS -A WITH_RTPPROXY` 13 | -------------------------------------------------------------------------------- /units/tmodxx0001/kamailio-allmods.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | loadmodule "pv.so" 4 | loadmodule "tm.so" 5 | 6 | loadmodule "acc.so" 7 | loadmodule "acc_diameter.so" 8 | loadmodule "acc_json.so" 9 | loadmodule "acc_radius.so" 10 | loadmodule "alias_db.so" 11 | # loadmodule "app_java.so" 12 | loadmodule "app_jsdt.so" 13 | loadmodule "app_lua.so" 14 | loadmodule "app_lua_sr.so" 15 | loadmodule "app_mono.so" 16 | loadmodule "app_perl.so" 17 | loadmodule "app_python.so" 18 | loadmodule "app_python3.so" 19 | loadmodule "app_python3s.so" 20 | loadmodule "app_ruby.so" 21 | #!ifdef KAMAILIO_5_7 22 | # loadmodule "app_ruby_proc.so" 23 | #!endif 24 | #!ifexp KAMAILIO_VERSION < 5008000 25 | loadmodule "app_sqlang.so" 26 | #!endif 27 | loadmodule "async.so" 28 | loadmodule "auth.so" 29 | loadmodule "auth_db.so" 30 | loadmodule "auth_diameter.so" 31 | loadmodule "auth_ephemeral.so" 32 | #!ifexp KAMAILIO_VERSION < 5008000 33 | loadmodule "auth_identity.so" 34 | #!endif 35 | loadmodule "auth_radius.so" 36 | loadmodule "auth_xkeys.so" 37 | loadmodule "avp.so" 38 | loadmodule "avpops.so" 39 | loadmodule "benchmark.so" 40 | loadmodule "blst.so" 41 | loadmodule "call_control.so" 42 | loadmodule "call_obj.so" 43 | loadmodule "carrierroute.so" 44 | loadmodule "cdp.so" 45 | loadmodule "cdp_avp.so" 46 | loadmodule "cfg_db.so" 47 | loadmodule "cfg_rpc.so" 48 | loadmodule "cfgt.so" 49 | loadmodule "cfgutils.so" 50 | loadmodule "cnxcc.so" 51 | loadmodule "corex.so" 52 | loadmodule "counters.so" 53 | loadmodule "cplc.so" 54 | loadmodule "crypto.so" 55 | loadmodule "ctl.so" 56 | loadmodule "db2_ldap.so" 57 | loadmodule "db2_ops.so" 58 | loadmodule "db_berkeley.so" 59 | # loadmodule "db_cassandra.so" 60 | loadmodule "db_cluster.so" 61 | loadmodule "db_flatstore.so" 62 | loadmodule "db_mongodb.so" 63 | loadmodule "db_mysql.so" 64 | # loadmodule "db_oracle.so" 65 | loadmodule "db_perlvdb.so" 66 | loadmodule "db_postgres.so" 67 | loadmodule "db_redis.so" 68 | loadmodule "db_sqlite.so" 69 | loadmodule "db_text.so" 70 | loadmodule "db_unixodbc.so" 71 | loadmodule "debugger.so" 72 | #!ifndef WITH_IMS 73 | loadmodule "dialog.so" 74 | #!endif 75 | loadmodule "dialplan.so" 76 | loadmodule "dispatcher.so" 77 | loadmodule "diversion.so" 78 | loadmodule "dmq.so" 79 | loadmodule "dmq_usrloc.so" 80 | # loadmodule "dnssec.so" 81 | loadmodule "domain.so" 82 | loadmodule "domainpolicy.so" 83 | loadmodule "drouting.so" 84 | loadmodule "enum.so" 85 | loadmodule "erlang.so" 86 | loadmodule "evapi.so" 87 | loadmodule "evrexec.so" 88 | loadmodule "exec.so" 89 | loadmodule "file_out.so" 90 | loadmodule "gcrypt.so" 91 | loadmodule "geoip.so" 92 | loadmodule "geoip2.so" 93 | loadmodule "group.so" 94 | loadmodule "gzcompress.so" 95 | loadmodule "h350.so" 96 | loadmodule "htable.so" 97 | loadmodule "http_async_client.so" 98 | loadmodule "http_client.so" 99 | loadmodule "imc.so" 100 | loadmodule "ims_auth.so" 101 | loadmodule "ims_charging.so" 102 | #!ifdef WITH_IMS 103 | loadmodule "ims_dialog.so" 104 | #!endif 105 | loadmodule "ims_diameter_server.so" 106 | loadmodule "ims_icscf.so" 107 | loadmodule "ims_ipsec_pcscf" 108 | loadmodule "ims_isc.so" 109 | loadmodule "ims_ocs.so" 110 | loadmodule "ims_qos.so" 111 | loadmodule "ims_registrar_pcscf.so" 112 | #!ifdef WITH_IMS 113 | loadmodule "ims_registrar_scscf.so" 114 | #!endif 115 | loadmodule "ims_usrloc_pcscf.so" 116 | loadmodule "ims_usrloc_scscf.so" 117 | loadmodule "influxdbc.so" 118 | loadmodule "ipops.so" 119 | loadmodule "jansson.so" 120 | loadmodule "janssonrpcc.so" 121 | loadmodule "json.so" 122 | loadmodule "jsonrpcc.so" 123 | loadmodule "jsonrpcs.so" 124 | # loadmodule "jwt.so" 125 | loadmodule "kafka.so" 126 | loadmodule "kazoo.so" 127 | loadmodule "keepalive.so" 128 | loadmodule "kemix.so" 129 | loadmodule "kex.so" 130 | loadmodule "lcr.so" 131 | loadmodule "ldap.so" 132 | loadmodule "log_custom.so" 133 | loadmodule "log_systemd.so" 134 | loadmodule "lost" 135 | loadmodule "lrkproxy" 136 | loadmodule "lwsc" 137 | #!ifexp KAMAILIO_VERSION >= 5007000 138 | loadmodule "math.so" 139 | #!endif 140 | #!ifexp KAMAILIO_VERSION >= 5007000 141 | loadmodule "misctest.so" 142 | #!else 143 | loadmodule "malloc_test.so" 144 | #!endif 145 | loadmodule "mangler.so" 146 | loadmodule "matrix.so" 147 | loadmodule "maxfwd.so" 148 | loadmodule "mediaproxy.so" 149 | loadmodule "memcached.so" 150 | loadmodule "microhttpd.so" 151 | loadmodule "misc_radius.so" 152 | loadmodule "mohqueue.so" 153 | loadmodule "mqtt.so" 154 | loadmodule "mqueue.so" 155 | loadmodule "msilo.so" 156 | loadmodule "msrp.so" 157 | loadmodule "mtree.so" 158 | loadmodule "nathelper.so" 159 | loadmodule "nat_traversal.so" 160 | # loadmodule "nats.so" 161 | # loadmodule "ndb_cassandra.so" 162 | loadmodule "ndb_mongodb.so" 163 | loadmodule "ndb_redis.so" 164 | loadmodule "nosip.so" 165 | # loadmodule "nsq.so" 166 | # loadmodule "osp.so" 167 | loadmodule "outbound.so" 168 | loadmodule "p_usrloc.so" 169 | loadmodule "path.so" 170 | loadmodule "pdb.so" 171 | loadmodule "pdt.so" 172 | loadmodule "peering.so" 173 | loadmodule "permissions.so" 174 | loadmodule "phonenum.so" 175 | loadmodule "pike.so" 176 | loadmodule "pipelimit.so" 177 | loadmodule "posops.so" 178 | loadmodule "prefix_route.so" 179 | loadmodule "presence.so" 180 | loadmodule "presence_conference.so" 181 | loadmodule "presence_dialoginfo.so" 182 | loadmodule "presence_mwi.so" 183 | loadmodule "presence_profile.so" 184 | loadmodule "presence_reginfo.so" 185 | loadmodule "presence_xml.so" 186 | loadmodule "print.so" 187 | loadmodule "print_lib.so" 188 | loadmodule "pua.so" 189 | loadmodule "pua_bla.so" 190 | loadmodule "pua_dialoginfo.so" 191 | loadmodule "pua_json" 192 | loadmodule "pua_reginfo.so" 193 | loadmodule "pua_rpc.so" 194 | loadmodule "pua_usrloc.so" 195 | loadmodule "pua_xmpp.so" 196 | loadmodule "pv_headers" 197 | loadmodule "qos.so" 198 | loadmodule "rabbitmq.so" 199 | loadmodule "ratelimit.so" 200 | loadmodule "regex.so" 201 | #!ifndef WITH_IMS 202 | loadmodule "registrar.so" 203 | #!endif 204 | loadmodule "rls.so" 205 | loadmodule "rr.so" 206 | loadmodule "rtimer.so" 207 | loadmodule "rtjson.so" 208 | loadmodule "rtp_media_server" 209 | #!ifndef WITH_RTPPROXY 210 | loadmodule "rtpengine.so" 211 | #!else 212 | loadmodule "rtpproxy.so" 213 | #!endif 214 | # loadmodule "ruxc.so" 215 | loadmodule "sanity.so" 216 | loadmodule "sca.so" 217 | loadmodule "sctp.so" 218 | loadmodule "sdpops.so" 219 | loadmodule "seas.so" 220 | loadmodule "secfilter" 221 | # loadmodule "secsipid" 222 | # loadmodule "secsipid_proc" 223 | loadmodule "sipcapture.so" 224 | loadmodule "sipdump.so" 225 | loadmodule "sipjson.so" 226 | loadmodule "siprepo.so" 227 | loadmodule "sipt.so" 228 | loadmodule "siptrace.so" 229 | loadmodule "siputils.so" 230 | loadmodule "sl.so" 231 | loadmodule "sms.so" 232 | loadmodule "smsops.so" 233 | loadmodule "snmpstats.so" 234 | loadmodule "speeddial.so" 235 | loadmodule "sqlops.so" 236 | loadmodule "ss7ops.so" 237 | loadmodule "sst.so" 238 | loadmodule "statistics.so" 239 | loadmodule "statsc.so" 240 | loadmodule "statsd.so" 241 | # loadmodule "stirshaken" 242 | loadmodule "stun.so" 243 | loadmodule "sworker" 244 | loadmodule "systemdops" 245 | loadmodule "tcpops.so" 246 | loadmodule "textops.so" 247 | loadmodule "textopsx.so" 248 | loadmodule "timer.so" 249 | loadmodule "tls.so" 250 | loadmodule "tlsa.so" 251 | #!ifexp KAMAILIO_VERSION >= 5007000 252 | loadmodule "tls_wolfssl.so" 253 | #!endif 254 | loadmodule "tmrec.so" 255 | loadmodule "tmx.so" 256 | loadmodule "topoh.so" 257 | loadmodule "topos.so" 258 | loadmodule "topos_redis.so" 259 | loadmodule "tsilo.so" 260 | loadmodule "uac.so" 261 | loadmodule "uac_redirect.so" 262 | loadmodule "uid_auth_db.so" 263 | loadmodule "uid_avp_db.so" 264 | loadmodule "uid_domain.so" 265 | loadmodule "uid_gflags.so" 266 | loadmodule "uid_uri_db.so" 267 | loadmodule "uri_db.so" 268 | #!ifexp KAMAILIO_VERSION >= 5005000 269 | loadmodule "userblocklist.so" 270 | #!else 271 | loadmodule "userblacklist.so" 272 | #!endif 273 | loadmodule "usrloc.so" 274 | loadmodule "utils.so" 275 | loadmodule "uuid.so" 276 | loadmodule "websocket.so" 277 | loadmodule "xcap_client.so" 278 | loadmodule "xcap_server.so" 279 | loadmodule "xhttp.so" 280 | loadmodule "xhttp_pi.so" 281 | loadmodule "xhttp_prom.so" 282 | loadmodule "xhttp_rpc.so" 283 | loadmodule "xlog.so" 284 | loadmodule "xmlops.so" 285 | loadmodule "xmlrpc.so" 286 | loadmodule "xmpp.so" 287 | loadmodule "xprint.so" 288 | 289 | request_route { 290 | exit; 291 | } 292 | -------------------------------------------------------------------------------- /units/tmodxx0001/tmodxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-allmods.cfg" 7 | ${KAMBIN} -f ./kamailio-allmods.cfg -dd -E 2>&1 | tee /tmp/kamailio-allmods.log 8 | echo 9 | echo "--- grep output" 10 | echo 11 | grep "undefined symbol" /tmp/kamailio-allmods.log 12 | ret=$? 13 | if [ ! "$ret" -eq 1 ] ; then 14 | exit 1 15 | fi 16 | echo "--- start kamailio -f ./kamailio-allmods.cfg -A WITH_IMS -A WITH_RTPPROXY" 17 | ${KAMBIN} -f ./kamailio-allmods.cfg -dd -E -A WITH_IMS -A WITH_RTPPROXY 2>&1 | tee /tmp/kamailio-allmods.log 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "undefined symbol" /tmp/kamailio-allmods.log 22 | ret=$? 23 | if [ ! "$ret" -eq 1 ] ; then 24 | exit 1 25 | fi 26 | exit 0 27 | -------------------------------------------------------------------------------- /units/tmtree0001/README.md: -------------------------------------------------------------------------------- 1 | # MTree - Basic Tests # 2 | 3 | Summary: mtree - basic tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tmtree0001.cfg` and do tests about loading, 8 | reloading and matching 9 | -------------------------------------------------------------------------------- /units/tmtree0001/kamailio-tmtree0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio" 6 | 7 | #!ifdef WITH_MULTIDOMAIN 8 | #!define MULTIDOMAIN 1 9 | #!else 10 | #!define MULTIDOMAIN 0 11 | #!endif 12 | 13 | loadmodule "db_mysql.so" 14 | loadmodule "jsonrpcs.so" 15 | loadmodule "kex.so" 16 | loadmodule "corex.so" 17 | loadmodule "tm.so" 18 | loadmodule "tmx.so" 19 | loadmodule "sl.so" 20 | loadmodule "pv.so" 21 | loadmodule "xlog.so" 22 | loadmodule "mtree.so" 23 | 24 | modparam("mtree", "db_url", DBURL) 25 | modparam("mtree", "mtree", "name=mtree;dbtable=mtree;type=0") 26 | modparam("mtree", "char_list", "0123456789*+") 27 | modparam("mtree", "pv_value", "$var(mtval)") 28 | 29 | request_route { 30 | 31 | mt_match("mtree", "$rU", "0"); 32 | 33 | xlog("===== tprefix $rU tvalue $var(mtval)\n"); 34 | sl_send_reply("200", "OK"); 35 | exit; 36 | } 37 | -------------------------------------------------------------------------------- /units/tmtree0001/tmtree0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- run: ${KAMCTL} mtree add mtree 1234567890 alice" 7 | ${KAMCTL} mtree add mtree 1234567890 alice 8 | echo "--- run: ${KAMCTL} mtree add mtree 2345678901 bob" 9 | ${KAMCTL} mtree add mtree 2345678901 bob 10 | ${KAMCTL} mtree show mtree 11 | ${KAMCTL} mtree dump mtree 12 | echo "--- start kamailio -f ./kamailio-tmtree0001.cfg" 13 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tmtree0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tmtree0001.log & 14 | ret=$? 15 | sleep 1 16 | sipsak -s sip:1234567890@127.0.0.1 17 | sleep 1 18 | echo "--- run: ${KAMCTL} mtree add mtree 3456789012 carol" 19 | ${KAMCTL} mtree add mtree 3456789012 carol 20 | echo "--- run: ${KAMCTL} mtree show mtree" 21 | ${KAMCTL} mtree show mtree 22 | echo "--- run: ${KAMCTL} mtree dump mtree" 23 | ${KAMCTL} mtree dump mtree 24 | echo "--- run: ${KAMCTL} mtree reload mtree" 25 | ${KAMCTL} mtree reload mtree 26 | echo "--- run: ${KAMCTL} mtree dump mtree" 27 | ${KAMCTL} mtree dump mtree 28 | sleep 1 29 | kill_pidfile ${KAMPID} 30 | sleep 1 31 | echo 32 | echo "--- grep output" 33 | echo 34 | grep "tprefix 1234567890 tvalue alice" /tmp/kamailio-tmtree0001.log 35 | ret=$? 36 | if [ ! "$ret" -eq 0 ] ; then 37 | exit 1 38 | fi 39 | exit 0 40 | -------------------------------------------------------------------------------- /units/tphonu0001/README.md: -------------------------------------------------------------------------------- 1 | # PhoneNum Module - Basic Tests # 2 | 3 | Summary: phonenum module - basic tests 4 | 5 | Following tests are done: 6 | 7 | * load phonenum module and test for numer +49-30-123456789 8 | -------------------------------------------------------------------------------- /units/tphonu0001/kamailio-tphonu0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | loadmodule "db_mysql.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "kex.so" 8 | loadmodule "corex.so" 9 | loadmodule "tm.so" 10 | loadmodule "tmx.so" 11 | loadmodule "sl.so" 12 | loadmodule "pv.so" 13 | loadmodule "xlog.so" 14 | loadmodule "phonenum.so" 15 | 16 | request_route { 17 | $var(i) = 0; 18 | $var(cname) = "US"; 19 | $var(pnum) = "1 (212) 937-7844"; 20 | route(PHONENUM); 21 | $var(i) = $var(i) + 1; 22 | $var(cname) = "US"; 23 | $var(pnum) = "1-484-555-8888"; 24 | route(PHONENUM); 25 | $var(i) = $var(i) + 1; 26 | $var(cname) = ""; 27 | $var(pnum) = "+49 800 330 1000"; 28 | route(PHONENUM); 29 | sl_send_reply("200", "OK"); 30 | exit; 31 | } 32 | 33 | route[PHONENUM] { 34 | if($(var(cname){s.len}) > 0) { 35 | phonenum_match_cn("$var(pnum)", "$var(cname)", "src"); 36 | $var(rc) = $rc; 37 | } else { 38 | phonenum_match("$var(pnum)", "src"); 39 | $var(rc) = $rc; 40 | } 41 | if($var(rc) > 0) { 42 | if($phn(src=>valid)==1) { 43 | xlog("$var(i) - number matched: $phn(src=>number)\n"); 44 | xlog("$var(i) - number valid: $phn(src=>valid)\n"); 45 | xlog("$var(i) - number normalized: $phn(src=>normalized)\n"); 46 | xlog("$var(i) - number cctel: $phn(src=>cctel)\n"); 47 | xlog("$var(i) - number ndesc: $phn(src=>ndesc)\n"); 48 | xlog("$var(i) - number ltype: $phn(src=>ltype)\n"); 49 | } else { 50 | xlog("$var(i) - number normalization error: $phn(src=>error)\n"); 51 | } 52 | } else { 53 | xlog("$var(i) - phonenum match failure\n"); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /units/tphonu0001/tphonu0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tphonu0001.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tphonu0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tphonu0001.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -s sip:alice@127.0.0.1 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | grep "number normalized" /tmp/kamailio-tphonu0001.log 18 | ret=$? 19 | rm -f /tmp/kamailio-tphonu0001.log 20 | if [ ! "$ret" -eq 0 ] ; then 21 | exit 1 22 | fi 23 | exit 0 24 | -------------------------------------------------------------------------------- /units/tpvxxx0001/README.md: -------------------------------------------------------------------------------- 1 | # pv - $xavi(...) Tests # 2 | 3 | Summary: pv - $xavi() tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tpvxxx0001.cfg and test if $xavi in config 8 | -------------------------------------------------------------------------------- /units/tpvxxx0001/kamailio-tpvxxx0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=1 4 | 5 | loadmodule "kex.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "tm.so" 8 | loadmodule "tmx.so" 9 | loadmodule "sl.so" 10 | loadmodule "rr.so" 11 | loadmodule "pv.so" 12 | loadmodule "textops.so" 13 | loadmodule "xlog.so" 14 | 15 | modparam("jsonrpcs", "pretty_format", 1) 16 | 17 | request_route { 18 | if (!is_method("MESSAGE")) exit; 19 | 20 | pv_unset("$xavi(FOO)"); 21 | $(xavi(FOO=>val)) = "testME"; 22 | pv_xavi_print(); 23 | if($xavi(fOo=>VAl) == "testME") { 24 | xlog("test$var(t): OK\n"); 25 | } else { 26 | xlog("test$var(t): $(xavi(FOO=>val[*]))\n"); 27 | } 28 | $var(t) = $var(t) + 1; 29 | 30 | xavi_rm("foo"); 31 | pv_xavi_print(); 32 | if(!pv_isset("$xavi(FOO=>val)")) { 33 | xlog("test$var(t): OK\n"); 34 | } else { 35 | xlog("test$var(t): $(xavi(FOO=>val[*]))\n"); 36 | } 37 | $var(t) = $var(t) + 1; 38 | 39 | send_reply("200", "OK"); 40 | } 41 | -------------------------------------------------------------------------------- /units/tpvxxx0001/tpvxxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | LOG=/tmp/kamailio-tpvxxx0001.log 7 | 8 | echo "--- start kamailio -f ./kamailio-tpvxxx0001.cfg" 9 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} \ 10 | -f ./kamailio-tpvxxx0001.cfg -a no -ddd -E 2>&1 | tee ${LOG} & 11 | sleep 1 12 | sipsak -M -s sip:test1test@127.0.0.1 13 | sleep 1 14 | kill_pidfile ${KAMPID} 15 | sleep 1 16 | echo 17 | echo "--- grep output" 18 | echo 19 | for i in 0 1; do 20 | if ! grep -q "test${i}: OK" ${LOG}; then 21 | echo "test${i} failed" 22 | exit 1 23 | fi 24 | done 25 | exit 0 26 | -------------------------------------------------------------------------------- /units/tregexxx0001/README.md: -------------------------------------------------------------------------------- 1 | # Regex - matches Tests # 2 | 3 | Summary: regex - check regex matches 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tregexxx0001.cfg send MESSAGE msg and check the 8 | output. Reload the regex_group file and recheck other rules. 9 | -------------------------------------------------------------------------------- /units/tregexxx0001/kamailio-tregexxx0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=1 4 | 5 | loadmodule "kex.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "ctl" 8 | loadmodule "sl.so" 9 | loadmodule "pv.so" 10 | loadmodule "textops.so" 11 | loadmodule "regex.so" 12 | loadmodule "xlog.so" 13 | 14 | modparam("jsonrpcs", "pretty_format", 1) 15 | modparam("regex", "file", "/tmp/regex_groups"); 16 | 17 | request_route { 18 | route(REGEX); 19 | exit; 20 | } 21 | 22 | route[REGEX] { 23 | if (!is_method("MESSAGE")) return; 24 | if (pcre_match("$rb", "^HOLA")) { 25 | xlog("L_INFO", "^HOLA matches\n"); 26 | } 27 | if (pcre_match("$rb", "^ADIOS")) { 28 | xlog("L_INFO", "^ADIOS matches\n"); 29 | } 30 | if (pcre_match_group("$rb", "0")) { 31 | xlog("L_INFO", "^HOLA group 0 matches\n"); 32 | } 33 | if (pcre_match_group("$rb", "0")) { 34 | xlog("L_INFO", "^ADIOS group 0 matches\n"); 35 | } 36 | sl_reply("200", "OK"); 37 | exit; 38 | } 39 | -------------------------------------------------------------------------------- /units/tregexxx0001/regex_group: -------------------------------------------------------------------------------- 1 | [0] 2 | ^ADIOS 3 | -------------------------------------------------------------------------------- /units/tregexxx0001/regex_groups: -------------------------------------------------------------------------------- 1 | [0] 2 | ^HOLA 3 | -------------------------------------------------------------------------------- /units/tregexxx0001/regex_groups_1: -------------------------------------------------------------------------------- 1 | [0] 2 | ^HOLA 3 | -------------------------------------------------------------------------------- /units/tregexxx0001/regex_groups_2: -------------------------------------------------------------------------------- 1 | [0] 2 | ^ADIOS 3 | -------------------------------------------------------------------------------- /units/tregexxx0001/tregexxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | LOG=/tmp/kamailio-tregexxx0001.log 7 | 8 | cp regex_groups_1 /tmp/regex_groups 9 | echo "--- start kamailio -f ./kamailio-tregexxx0001.cfg" 10 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} \ 11 | -f ./kamailio-tregexxx0001.cfg -a no -ddd -E 2>&1 | tee ${LOG} & 12 | ret=$? 13 | sleep 1 14 | sipsak -s sip:test@127.0.0.1 -B "HOLA caracola" 15 | 16 | echo "--- regex reload ---" 17 | cp regex_groups_2 /tmp/regex_group 18 | ${KAMCTL} kamcmd regex.reload 19 | sleep 1 20 | sipsak -s sip:test@127.0.0.1 -B "ADIOS caracola" 21 | sleep 1 22 | kill_pidfile ${KAMPID} 23 | sleep 1 24 | echo 25 | echo "--- grep output" 26 | echo 27 | 28 | if ! grep -q '\^HOLA matches' ${LOG} ; then 29 | exit 1 30 | fi 31 | if ! grep -q '\^HOLA group 0 matches' ${LOG} ; then 32 | exit 1 33 | fi 34 | 35 | if ! grep -q '\^ADIOS matches' ${LOG} ; then 36 | exit 1 37 | fi 38 | if ! grep -q '\^ADIOS group 0 matches' ${LOG} ; then 39 | exit 1 40 | fi 41 | exit 0 42 | 43 | -------------------------------------------------------------------------------- /units/tregxx0001/README.md: -------------------------------------------------------------------------------- 1 | # Registrar - xavp_rcd Tests # 2 | 3 | Summary: registrar - check xavp_rcd values 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tregxx0001.cfg send a REGISTER msg and check the 8 | xavp_rcd values depending of the xavp_rcd_mask paramater after save(), send 9 | a MESSAGE msg and check xavp_rcd values depending of the xavp_rcd_mask 10 | paramater after lookup(). 11 | 12 | * run that check for different values of xavp_rcd_mask 13 | -------------------------------------------------------------------------------- /units/tregxx0001/kamailio-tregxx0001-inc: -------------------------------------------------------------------------------- 1 | modparam("registrar", "xavp_rcd_mask", #mask#) 2 | -------------------------------------------------------------------------------- /units/tregxx0001/kamailio-tregxx0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=1 4 | 5 | loadmodule "kex.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "tm.so" 8 | loadmodule "tmx.so" 9 | loadmodule "sl.so" 10 | loadmodule "rr.so" 11 | loadmodule "pv.so" 12 | loadmodule "textops.so" 13 | loadmodule "usrloc.so" 14 | loadmodule "registrar.so" 15 | loadmodule "xlog.so" 16 | 17 | modparam("jsonrpcs", "pretty_format", 1) 18 | 19 | modparam("registrar", "xavp_rcd", "rcd") 20 | 21 | include_file "kamailio-tregxx0001-inc.cfg" 22 | 23 | request_route { 24 | route(REGISTRAR); 25 | route(LOCATION); 26 | exit; 27 | } 28 | 29 | route[REGISTRAR] { 30 | if (!is_method("REGISTER")) return; 31 | xlog("registrar: $ru\n"); 32 | if (!save("location")) { 33 | sl_reply_error(); 34 | } 35 | route(CHECK); 36 | exit; 37 | } 38 | 39 | route[LOCATION] { 40 | if (!is_method("MESSAGE")) return; 41 | if (!lookup("location", "sip:test@127.2.2.1:5066")) { 42 | $var(rc) = $rc; 43 | t_newtran(); 44 | switch ($var(rc)) { 45 | case -1: 46 | case -3: 47 | send_reply("404", "Not Found"); 48 | exit; 49 | case -2: 50 | send_reply("405", "Method Not Allowed"); 51 | exit; 52 | } 53 | } else { 54 | send_reply("200", "OK"); 55 | } 56 | route(CHECK); 57 | return; 58 | } 59 | 60 | route[CHECK] { 61 | pv_xavp_print(); 62 | if(pv_isset("$xavp(rcd[0]=>ruid)")) { 63 | xlog("check[$rm]: ruid exists\n"); 64 | } 65 | if(pv_isset("$xavp(rcd[0]=>contact)")) { 66 | xlog("check[$rm]: contact exists\n"); 67 | } 68 | if(pv_isset("$xavp(rcd[0]=>expires)")) { 69 | xlog("check[$rm]: expires exists\n"); 70 | } 71 | if(pv_isset("$xavp(rcd[0]=>received)")) { 72 | xlog("check[$rm]: received exists\n"); 73 | } 74 | if(pv_isset("$xavp(rcd[0]=>path)")) { 75 | xlog("check[$rm]: path exists\n"); 76 | } 77 | return; 78 | } 79 | -------------------------------------------------------------------------------- /units/tregxx0001/tregxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | LOG=/tmp/kamailio-tregxx0001.log 7 | 8 | function run() { 9 | sed -e "s/#mask#/${mask}/g" ./kamailio-tregxx0001-inc > ./kamailio-tregxx0001-inc.cfg 10 | echo "--- start kamailio -f ./kamailio-tregxx0001.cfg with mask $mask" 11 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} \ 12 | -f ./kamailio-tregxx0001.cfg -a no -ddd -E 2>&1 | tee ${LOG} & 13 | sleep 1 14 | sipsak -U -s sip:test@127.0.0.1 -C sip:test@127.2.2.1:5066 15 | sipsak -M -s sip:test@127.0.0.1 16 | sleep 1 17 | kill_pidfile ${KAMPID} 18 | sleep 1 19 | } 20 | 21 | function check() { 22 | local val=${1} 23 | local mask=${2} 24 | if ! grep -q "check\\[REGISTER\\]: ${val} exists" ${LOG} ; then 25 | echo "[${mask}] ${val} not found in REGISTER" 26 | exit 1 27 | fi 28 | if ! grep -q "check\\[MESSAGE\\]: ${val} exists" ${LOG}; then 29 | echo "[${mask}] ${val} not found in REGISTER" 30 | exit 1 31 | 32 | fi 33 | } 34 | 35 | function check_not() { 36 | val=${1} 37 | if grep -q "check\\[REGISTER\\]: ${val} exists" ${LOG} ; then 38 | echo "[${mask}] ${val} found in REGISTER" 39 | exit 1 40 | fi 41 | if grep -q "check\\[MESSAGE\\]: ${val} exists" ${LOG}; then 42 | echo "[${mask}] ${val} found in REGISTER" 43 | exit 1 44 | 45 | fi 46 | } 47 | 48 | echo 49 | echo "--- grep output" 50 | echo 51 | 52 | mask=0 53 | run 54 | check ruid 55 | check contact 56 | check expires 57 | 58 | mask=1 59 | run 60 | check_not ruid 61 | check contact 62 | check expires 63 | 64 | mask=2 65 | run 66 | check ruid 67 | check_not contact 68 | check expires 69 | 70 | mask=3 71 | run 72 | check_not ruid 73 | check_not contact 74 | check expires 75 | 76 | mask=4 77 | run 78 | check ruid 79 | check contact 80 | check_not expires 81 | 82 | mask=5 83 | run 84 | check_not ruid 85 | check contact 86 | check_not expires 87 | 88 | mask=6 89 | run 90 | check ruid 91 | check_not contact 92 | check_not expires 93 | 94 | mask=7 95 | run 96 | check_not ruid 97 | check_not contact 98 | check_not expires 99 | 100 | exit 0 101 | -------------------------------------------------------------------------------- /units/tregxx0002/README.md: -------------------------------------------------------------------------------- 1 | # Registrar - xavp_rcd Tests # 2 | 3 | Summary: registrar - check xavp_rcd values 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with kamailio-tregxx0002.cfg sends different REGISTER msg 8 | (three contacts for the same user ) and check the xavp_rcd values after 9 | save() 10 | 11 | -------------------------------------------------------------------------------- /units/tregxx0002/kamailio-tregxx0002.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=1 4 | 5 | loadmodule "kex.so" 6 | loadmodule "jsonrpcs.so" 7 | loadmodule "tm.so" 8 | loadmodule "tmx.so" 9 | loadmodule "sl.so" 10 | loadmodule "rr.so" 11 | loadmodule "pv.so" 12 | loadmodule "textops.so" 13 | loadmodule "usrloc.so" 14 | loadmodule "registrar.so" 15 | loadmodule "xlog.so" 16 | loadmodule "app_lua.so" 17 | 18 | modparam("jsonrpcs", "pretty_format", 1) 19 | 20 | modparam("app_lua", "load", "/usr/local/src/kamailio-tests/units/tregxx0002/kamailio-tregxx0002.lua") 21 | 22 | modparam("registrar", "xavp_rcd", "rcd") 23 | modparam("registrar", "use_path", 1) 24 | modparam("registrar", "path_use_received", 1) 25 | 26 | request_route { 27 | route(REGISTRAR); 28 | exit; 29 | } 30 | 31 | route[REGISTRAR] { 32 | if (!is_method("REGISTER")) return; 33 | xavp_rm("rcd"); 34 | if (!save("location")) { 35 | sl_reply_error(); 36 | } 37 | xlog("set: ruid$var(tmp) $xavp(rcd=>ruid[0])\n"); 38 | $var(tmp) = $var(tmp) + 1; 39 | route(CHECK); 40 | exit; 41 | } 42 | 43 | route[CHECK] { 44 | pv_xavp_print(); 45 | lua_run("check"); 46 | return; 47 | } 48 | -------------------------------------------------------------------------------- /units/tregxx0002/kamailio-tregxx0002.lua: -------------------------------------------------------------------------------- 1 | -- luacheck: globals KSR 2 | function check () 3 | local fields = {'ruid', 'expires', 'contact', 'received', 'path'} 4 | local str_x = '$xavp(rcd[0]=>%s[%d])' 5 | local str_y = 'check: %s%d exists\n' 6 | local val 7 | 8 | for i=0,2 do 9 | for _,field in ipairs(fields) do 10 | local xavp = string.format(str_x, field, i) 11 | val = KSR.pv.get(xavp) 12 | if val then 13 | local tmp = string.format('val %s%d:%s\n', field, i, tostring(val)) 14 | KSR.dbg(tmp) 15 | KSR.err(string.format(str_y, field, i)) 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /units/tregxx0002/tregxx0002.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | LOG=/tmp/kamailio-tregxx0001.log 7 | 8 | function run() { 9 | echo "--- start kamailio -f ./kamailio-tregxx0002.cfg" 10 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} \ 11 | -f ./kamailio-tregxx0002.cfg -a no -ddd -E 2>&1 | tee ${LOG} & 12 | sleep 1 13 | sipsak -U -s sip:test@127.0.0.1 -C sip:test@127.2.2.1:5066 14 | sipsak -U -s sip:test@127.0.0.1 -C sip:test@127.2.2.2:5066 15 | sipsak -U -s sip:test@127.0.0.1 -C sip:test@127.2.2.3:5066 16 | sleep 1 17 | kill_pidfile ${KAMPID} 18 | sleep 1 19 | } 20 | 21 | function _check_save() { 22 | local val=${1} 23 | local index=${2} 24 | # build_contact() has only those two for now 25 | if [[ "${val}" =~ ruid|expires ]]; then 26 | if ! grep -q "check: ${val}${index} exists" ${LOG} ; then 27 | echo "${val}[${index}] not found" 28 | exit 1 29 | fi 30 | else 31 | if grep -q "check: ${val}${index} exists" ${LOG} ; then 32 | echo "${val}[${index}] found" 33 | exit 1 34 | fi 35 | fi 36 | } 37 | 38 | function _check_value() { 39 | local field=${1} 40 | local val=${2} 41 | if ! grep -q "val ${field}:${val}" ${LOG} ; then 42 | echo "${field} val not ${val}" 43 | grep "val ${field}:" ${LOG} 44 | exit 1 45 | fi 46 | } 47 | 48 | function check_save() { 49 | local i 50 | local field 51 | for i in 0 1 2; do 52 | for field in ruid expires; do 53 | _check_save ${field} ${i} 54 | done 55 | done 56 | } 57 | 58 | function check_order() { 59 | local indx=0 60 | local i 61 | for i in $(awk '/set: ruid/ { print $6}' ${LOG}| sort -r | xargs); do 62 | _check_value ruid${indx} ${i} 63 | (( indx++ )) 64 | done 65 | } 66 | 67 | echo 68 | echo "--- grep output" 69 | echo 70 | 71 | run 72 | check_save 73 | check_order 74 | 75 | exit 0 76 | -------------------------------------------------------------------------------- /units/tsiput0001/README.md: -------------------------------------------------------------------------------- 1 | # SIPUTILS - Basic Tests # 2 | 3 | Summary: siputils - basic tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tsiput0001.cfg` and do tests with sample SIP 8 | traffic 9 | -------------------------------------------------------------------------------- /units/tsiput0001/kamailio-tsiput0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | loadmodule "jsonrpcs.so" 6 | loadmodule "kex.so" 7 | loadmodule "corex.so" 8 | loadmodule "tm.so" 9 | loadmodule "tmx.so" 10 | loadmodule "sl.so" 11 | loadmodule "pv.so" 12 | loadmodule "xlog.so" 13 | loadmodule "siputils.so" 14 | 15 | request_route { 16 | 17 | if (is_tel_number("$rU")) { 18 | xlog("ruri user $rU is tel number\n"); 19 | } else { 20 | xlog("ruri user $rU is not tel number\n"); 21 | } 22 | if (is_tel_number("+24242424")) { 23 | xlog("+24242424 is tel number\n"); 24 | } else { 25 | xlog("+24242424 is not tel number\n"); 26 | } 27 | 28 | if (is_numeric("$rU")) { 29 | xlog("ruri user $rU is numeric\n"); 30 | } else { 31 | xlog("ruri user $rU is not numeric\n"); 32 | } 33 | if (is_numeric("+24242424")) { 34 | xlog("+24242424 is numeric\n"); 35 | } else { 36 | xlog("+24242424 is not numeric\n"); 37 | } 38 | 39 | if (is_alphanum("$rU")) { 40 | xlog("ruri user $rU is alpha-numeric\n"); 41 | } else { 42 | xlog("ruri user $rU is not alpha-numeric\n"); 43 | } 44 | if (is_alphanum("+24242424")) { 45 | xlog("+24242424 is alpha-numeric\n"); 46 | } else { 47 | xlog("+24242424 is not alpha-numeric\n"); 48 | } 49 | 50 | if (is_alphanumex("$rU", "+.-_")) { 51 | xlog("ruri user $rU is extended alpha-numeric\n"); 52 | } else { 53 | xlog("ruri user $rU is not extended alpha-numeric\n"); 54 | } 55 | if (is_alphanumex("+24242424", "+.-_")) { 56 | xlog("+24242424 is extended alpha-numeric\n"); 57 | } else { 58 | xlog("+24242424 is not extended alpha-numeric\n"); 59 | } 60 | 61 | sl_send_reply("200", "OK"); 62 | exit; 63 | } 64 | -------------------------------------------------------------------------------- /units/tsiput0001/tsiput0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tsiput0001.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tsiput0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tsiput0001.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -s sip:alice@127.0.0.1 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | 18 | grep "ruri user alice is not tel number" /tmp/kamailio-tsiput0001.log 19 | ret=$? 20 | if [ ! "$ret" -eq 0 ] ; then 21 | exit 1 22 | fi 23 | grep "\+24242424 is tel number" /tmp/kamailio-tsiput0001.log 24 | ret=$? 25 | if [ ! "$ret" -eq 0 ] ; then 26 | exit 1 27 | fi 28 | grep "uri user alice is not numeric" /tmp/kamailio-tsiput0001.log 29 | ret=$? 30 | if [ ! "$ret" -eq 0 ] ; then 31 | exit 1 32 | fi 33 | grep "\+24242424 is not numeric" /tmp/kamailio-tsiput0001.log 34 | ret=$? 35 | if [ ! "$ret" -eq 0 ] ; then 36 | exit 1 37 | fi 38 | grep "ruri user alice is alpha-numeric" /tmp/kamailio-tsiput0001.log 39 | ret=$? 40 | if [ ! "$ret" -eq 0 ] ; then 41 | exit 1 42 | fi 43 | grep "\+24242424 is not alpha-numeric" /tmp/kamailio-tsiput0001.log 44 | ret=$? 45 | if [ ! "$ret" -eq 0 ] ; then 46 | exit 1 47 | fi 48 | grep "ruri user alice is extended alpha-numeric" /tmp/kamailio-tsiput0001.log 49 | ret=$? 50 | if [ ! "$ret" -eq 0 ] ; then 51 | exit 1 52 | fi 53 | grep "\+24242424 is extended alpha-numeric" /tmp/kamailio-tsiput0001.log 54 | ret=$? 55 | if [ ! "$ret" -eq 0 ] ; then 56 | exit 1 57 | fi 58 | 59 | exit 0 60 | -------------------------------------------------------------------------------- /units/tsjlua0001/README.md: -------------------------------------------------------------------------------- 1 | # SIPJSON - Tests With Lua Scripts # 2 | 3 | Summary: sipjson - tests with Lua scripts 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tsjlua0001.cfg` and do tests with sample SIP 8 | traffic and Lua scripts 9 | -------------------------------------------------------------------------------- /units/tsjlua0001/kamailio-tsjlua0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | loadmodule "jsonrpcs.so" 6 | loadmodule "kex.so" 7 | loadmodule "corex.so" 8 | loadmodule "tm.so" 9 | loadmodule "tmx.so" 10 | loadmodule "sl.so" 11 | loadmodule "pv.so" 12 | loadmodule "xlog.so" 13 | loadmodule "sipjson.so" 14 | loadmodule "app_lua.so" 15 | 16 | modparam("app_lua", "load", "/tmp/kamailio-tsjlua0001.lua") 17 | 18 | cfgengine "lua" 19 | -------------------------------------------------------------------------------- /units/tsjlua0001/kamailio-tsjlua0001.lua: -------------------------------------------------------------------------------- 1 | local cjson = require "cjson" 2 | 3 | function ksr_request_route() 4 | 5 | KSR.sipjson.sj_serialize("0B", "$var(json)"); 6 | 7 | local vjson = KSR.pv.getw("$var(json)"); 8 | if string.len(vjson) < 10 then 9 | KSR.dbg("===== short json:\n" .. vjson .. "\n"); 10 | KSR.sl.sl_send_reply("200", "OK"); 11 | KSR.x.exit(); 12 | end 13 | 14 | local sjv = cjson.decode(vjson); 15 | if sjv["rU"] == nil or string.len(sjv["rU"]) < 1 then 16 | KSR.dbg("===== rU key is not set\n"); 17 | else 18 | KSR.dbg("===== rU key is set: " .. sjv["rU"] .. "\n"); 19 | end 20 | 21 | KSR.dbg("===== long json:\n" .. vjson .. "\n"); 22 | KSR.sl.sl_send_reply("200", "OK"); 23 | KSR.x.exit(); 24 | 25 | end 26 | -------------------------------------------------------------------------------- /units/tsjlua0001/tsjlua0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | cp kamailio-tsjlua0001.lua /tmp/ 7 | echo "--- start kamailio -f ./kamailio-tsjlua0001.cfg" 8 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tsjlua0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tsjlua0001.log & 9 | ret=$? 10 | sleep 1 11 | sipsak -s sip:alice@127.0.0.1 12 | sleep 1 13 | kill_pidfile ${KAMPID} 14 | sleep 1 15 | rm /tmp/kamailio-tsjlua0001.lua 16 | echo 17 | echo "--- grep output" 18 | echo 19 | grep "rU\":\"alice" /tmp/kamailio-tsjlua0001.log 20 | ret=$? 21 | if [ ! "$ret" -eq 0 ] ; then 22 | exit 1 23 | fi 24 | exit 0 25 | -------------------------------------------------------------------------------- /units/tsjson0001/README.md: -------------------------------------------------------------------------------- 1 | # SIPJSON - Basic Tests # 2 | 3 | Summary: sipjson - basic tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with `kamailio-tsjson0001.cfg` and do tests with sample SIP 8 | traffic 9 | -------------------------------------------------------------------------------- /units/tsjson0001/kamailio-tsjson0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | 3 | children=2 4 | 5 | loadmodule "jsonrpcs.so" 6 | loadmodule "kex.so" 7 | loadmodule "corex.so" 8 | loadmodule "tm.so" 9 | loadmodule "tmx.so" 10 | loadmodule "sl.so" 11 | loadmodule "pv.so" 12 | loadmodule "xlog.so" 13 | loadmodule "sipjson.so" 14 | 15 | request_route { 16 | 17 | sj_serialize("0B", "$var(json)"); 18 | 19 | xlog("===== json:\n$var(json)\n"); 20 | sl_send_reply("200", "OK"); 21 | exit; 22 | } 23 | -------------------------------------------------------------------------------- /units/tsjson0001/tsjson0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tsjson0001.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tsjson0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tsjson0001.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -s sip:alice@127.0.0.1 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | grep "rU\":\"alice" /tmp/kamailio-tsjson0001.log 18 | ret=$? 19 | if [ ! "$ret" -eq 0 ] ; then 20 | exit 1 21 | fi 22 | exit 0 23 | -------------------------------------------------------------------------------- /units/ttlsxx0001/README.md: -------------------------------------------------------------------------------- 1 | # TLS configuration - Basic Tests # 2 | 3 | Summary: tls configiguration - basic test 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with default config and -A WITH_TLS 8 | -------------------------------------------------------------------------------- /units/ttlsxx0001/ttlsxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo 7 | echo "--- start with default config and -A WITH_TLS" 8 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no -A WITH_TLS -ddd -E 2>&1 | tee /tmp/kamailio-ttlsxx0001.log & 9 | ret=$? 10 | sleep 1 11 | timeout 3 openssl s_client -connect 127.0.0.1:5061 -showcerts 12 | kill_pidfile ${KAMPID} 13 | if [ ! "$ret" -eq 0 ] ; then 14 | exit $ret 15 | fi 16 | sleep 1 17 | echo 18 | echo "--- grep output" 19 | echo 20 | grep "TLS accept successful" /tmp/kamailio-ttlsxx0001.log 21 | ret=$? 22 | if [ ! "$ret" -eq 0 ] ; then 23 | exit 1 24 | fi 25 | 26 | exit $ret 27 | -------------------------------------------------------------------------------- /units/tuacxx0001/README.md: -------------------------------------------------------------------------------- 1 | # UAC Module - UAC Request Send Tests # 2 | 3 | Summary: uac module - uac_req_send() tests 4 | 5 | Following tests are done: 6 | 7 | * send an INFO request and authenticate it 8 | -------------------------------------------------------------------------------- /units/tuacxx0001/kamailio-tuacxx0001.cfg: -------------------------------------------------------------------------------- 1 | #!KAMAILIO 2 | # 3 | # Kamailio (OpenSER) SIP Server v5.3 - default configuration script 4 | # - web: https://www.kamailio.org 5 | # - git: https://github.com/kamailio/kamailio 6 | # 7 | debug=3 8 | log_stderror=yes 9 | 10 | memdbg=5 11 | memlog=5 12 | 13 | log_facility=LOG_LOCAL0 14 | log_prefix="{$mt $hdr(CSeq) $ci} " 15 | 16 | /* number of SIP routing processes */ 17 | children=2 18 | 19 | loadmodule "jsonrpcs.so" 20 | loadmodule "kex.so" 21 | loadmodule "corex.so" 22 | loadmodule "tm.so" 23 | loadmodule "tmx.so" 24 | loadmodule "sl.so" 25 | loadmodule "rr.so" 26 | loadmodule "pv.so" 27 | loadmodule "maxfwd.so" 28 | loadmodule "textops.so" 29 | loadmodule "xlog.so" 30 | 31 | loadmodule "auth.so" 32 | loadmodule "uac.so" 33 | 34 | # ----- tm params ----- 35 | # auto-discard branches from previous serial forking leg 36 | modparam("tm", "failure_reply_mode", 3) 37 | # default retransmission timeout: 30sec 38 | modparam("tm", "fr_timer", 30000) 39 | # default invite retransmission timeout after 1xx: 120sec 40 | modparam("tm", "fr_inv_timer", 120000) 41 | 42 | # ----- rr params ----- 43 | # set next param to 1 to add value to ;lr param (helps with some UAs) 44 | modparam("rr", "enable_full_lr", 0) 45 | # do not append from tag to the RR (no need for this script) 46 | modparam("rr", "append_fromtag", 1) 47 | 48 | 49 | ####### Routing Logic ######## 50 | 51 | 52 | /* Main SIP request routing logic 53 | * - processing of any incoming SIP request starts with this route 54 | * - note: this is the same as route { ... } */ 55 | request_route { 56 | 57 | if(is_method("OPTIONS")) { 58 | sl_send_reply("200", "ok"); 59 | $uac_req(method)="INFO"; 60 | $uac_req(ruri)="sip:test@" + $Ri; 61 | $uac_req(furi)="sip:test@" + $Ri; 62 | $uac_req(turi)="sip:test@" + $Ri; 63 | $uac_req(auser)="test"; 64 | $uac_req(apasswd)="test123"; 65 | uac_req_send(); 66 | exit; 67 | } 68 | if(is_method("INFO")) { 69 | if (!pv_auth_check("$fd", "test123", "0", "1")) { 70 | auth_challenge("$fd", "0"); 71 | exit; 72 | } 73 | xlog("info request authenticated\n"); 74 | } 75 | sl_send_reply("200", "ok"); 76 | } 77 | -------------------------------------------------------------------------------- /units/tuacxx0001/tuacxx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo "--- start kamailio -f ./kamailio-tuacxx0001.cfg" 7 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -f ./kamailio-tuacxx0001.cfg -a no -ddd -E 2>&1 | tee /tmp/kamailio-tuacxx0001.log & 8 | ret=$? 9 | sleep 1 10 | sipsak -s sip:test@127.0.0.1 11 | sleep 1 12 | kill_pidfile ${KAMPID} 13 | sleep 1 14 | echo 15 | echo "--- grep output" 16 | echo 17 | grep "info request authenticated" /tmp/kamailio-tuacxx0001.log 18 | ret=$? 19 | rm -f /tmp/kamailio-tuacxx0001.log 20 | if [ ! "$ret" -eq 0 ] ; then 21 | exit 1 22 | fi 23 | exit 0 24 | -------------------------------------------------------------------------------- /units/tulocx0001/README.md: -------------------------------------------------------------------------------- 1 | # User Location - Basic Tests # 2 | 3 | Summary: user location - basic tests 4 | 5 | Following tests are done: 6 | 7 | * run kamailio with default config file, do a registration and a signaling 8 | only call using sipsak 9 | -------------------------------------------------------------------------------- /units/tulocx0001/tulocx0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . ../../etc/config 4 | . ../../libs/utils 5 | 6 | echo 7 | echo "--- start with default config: ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no" 8 | ${KAMBIN} -P ${KAMPID} -w ${KAMRUN} -Y ${KAMRUN} -a no 9 | ret=$? 10 | sleep 1 11 | if [ ! "$ret" -eq 0 ] ; then 12 | exit $ret 13 | fi 14 | echo 15 | echo "--- start sipsak -vvv -U -i -l 15098 -H 127.0.0.1 -s sip:alice@127.0.0.1" 16 | sipsak -vvv -U -i -l 15098 -H 127.0.0.1 -s sip:alice@127.0.0.1:5060 2>&1 | tee /tmp/kamailio-tulocx0001.log & 17 | sleep 1 18 | echo 19 | echo "--- grep output" 20 | echo 21 | grep "SIP/2.0 200 OK" /tmp/kamailio-tulocx0001.log 22 | ret=$? 23 | if [ ! "$ret" -eq 0 ] ; then 24 | exit 1 25 | fi 26 | kill_pidfile ${KAMPID} 27 | 28 | exit $ret 29 | --------------------------------------------------------------------------------