Skip to content
Snippets Groups Projects
Commit 58914795 authored by Alexandre Savard's avatar Alexandre Savard Committed by Tristan Matthews
Browse files

#9619: update python interface and script account registration

parent 1c9d7cab
No related branches found
No related tags found
No related merge requests found
......@@ -348,7 +348,7 @@ class SflPhoneCtrlSimple(Thread):
if self.account is None:
raise SflPhoneError("No provided or current account !")
account = self.account
return self.getAccountDetails(account)['Status'] == "REGISTERED"
return self.getAccountDetails(account)['Registration.Status'] == "REGISTERED"
def isAccountEnable(self, account=None):
......@@ -369,11 +369,11 @@ class SflPhoneCtrlSimple(Thread):
if enable == True:
details = self.getAccountDetails(account)
details['Account.enable'] = "TRUE"
details['Account.enable'] = "true"
self.configurationmanager.setAccountDetails(account, details)
else:
details = self.getAccountDetails(account)
details['Account.enable'] = "FALSE"
details['Account.enable'] = "false"
self.configurationmanager.setAccountDetails(account, details)
def checkAccountExists(self, account=None):
......
#!/usr/bin/env python
#
# Copyright (C) 2009 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import time
import logging
from sflphonectrlsimple import SflPhoneCtrlSimple
from nose.tools import nottest
###
### function starting with 'test' are executed.
###
# Open sflphone and connect to sflphoned through dbus
sflphone = SflPhoneCtrlSimple(True)
accountList = ["IP2IP", "Account:1332798167"]
class TestSFLPhoneAccountConfig:
def __init__(self):
self.logger = logging.getLogger("TestSFLPhoneAccountConfig")
filehdlr = logging.FileHandler("/tmp/sflphonedbustest.log")
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
filehdlr.setFormatter(formatter)
self.logger.addHandler(filehdlr)
self.logger.setLevel(logging.INFO)
@nottest
def test_get_account_list(self):
self.logger.info("Test get account list")
accList = sflphone.getAllAccounts()
listIntersection = set(accList) & set(accountList)
assert len(listIntersection) == len(accountList)
@nottest
def test_account_registration(self):
self.logger.info("Test account registration")
accList = [x for x in sflphone.getAllAccounts() if x != "IP2IP"]
for acc in accList:
self.logger.info("Registering account " + acc)
if sflphone.isAccountEnable(acc):
sflphone.setAccountEnable(acc, False)
time.sleep(2)
# Account should not be registered
assert sflphone.isAccountRegistered(acc)
sflphone.setAccountEnable(acc, True)
time.sleep(2)
assert sflphone.isAccountRegistered(acc)
@nottest
def test_add_remove_account(self):
self.logger.info("Test add/remove account")
accountDetails = {}
newAccList = []
# consider only true accounts
accList = [x for x in sflphone.getAllAccounts() if x != "IP2IP"]
# Store the account details localy
for acc in accList:
accountDetails[acc] = sflphone.getAccountDetails(acc)
# Remove all accounts from sflphone
for acc in accountDetails:
sflphone.removeAccount(acc)
# Recreate all accounts
for acc in accountDetails:
newAccList.append(sflphone.addAccount(accountDetails[acc]))
# New accounts should be automatically registered
for acc in newAccList:
assert sflphone.isAccountRegistered(acc)
<?xml version="1.0" encoding="ISO-8859-2" ?>
<!-- Use with CSV file struct like: 3000;192.168.1.106;[authentication username=3000 password=3000];
(user part of uri, server address, auth tag in each line)
-->
<scenario name="register_client">
<send retrans="500">
<![CDATA[
REGISTER sip:127.0.0.1 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:300@127.0.0.1>;tag=[call_number]
To: <sip:300@127.0.0.1>
Call-ID: [call_id]
CSeq: [cseq] REGISTER
Contact: sip:300@[local_ip]:[local_port]
Max-Forwards: 10
Expires: 120
User-Agent: SIPp/Win32
Content-Length: 0
]]>
</send>
<!-- asterisk -->
<recv response="200">
<!--
<action>
<ereg regexp=".*" search_in="hdr" header="Contact:" check_it="true" assign_to="1" />
</action>
-->
</recv>
<!--
<recv request="INVITE" crlf="true">
</recv>
<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>
<send retrans="500">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv request="ACK"
optional="true"
rtd="true"
crlf="true">
</recv>
<recv request="BYE">
</recv>
<send>
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>
<timewait milliseconds="4000"/>
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
-->
</scenario>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment