Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/sippy_cup/scenario.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def invite(opts = {})
opts[:retrans] ||= 500
# FIXME: The DTMF mapping (101) is hard-coded. It would be better if we could
# get this from the DTMF payload generator
from_addr = "#{@from_user}@#{@adv_ip}:[local_port]"
from_addr = "#{@from_user}@#{@from_domain || @adv_ip}:[local_port]"
msg = <<-MSG

INVITE sip:#{to_addr} SIP/2.0
Expand Down Expand Up @@ -447,7 +447,7 @@ def ack_answer(opts = {})

ACK [next_url] SIP/2.0
Via: SIP/2.0/[transport] #{@adv_ip}:[local_port];branch=[branch]
From: "#{@from_user}" <sip:#{@from_user}@#{@adv_ip}:[local_port]>;tag=[call_number]
From: "#{@from_user}" <sip:#{@from_user}@#{@from_domain || @adv_ip}:[local_port]>;tag=[call_number]
To: <sip:#{to_addr}>[peer_tag_param]
Call-ID: [call_id]
CSeq: [cseq] ACK
Expand Down Expand Up @@ -498,7 +498,7 @@ def send_digits(digits)

INFO [next_url] SIP/2.0
Via: SIP/2.0/[transport] #{@adv_ip}:[local_port];branch=[branch]
From: "#{@from_user}" <sip:#{@from_user}@#{@adv_ip}:[local_port]>;tag=[call_number]
From: "#{@from_user}" <sip:#{@from_user}@#{@from_domain || @adv_ip}:[local_port]>;tag=[call_number]
To: <sip:#{to_addr}>[peer_tag_param]
Call-ID: [call_id]
CSeq: [cseq] INFO
Expand Down Expand Up @@ -779,6 +779,7 @@ def parse_args(args)
end

@from_user = args[:from_user] || "sipp"
@from_domain = args[:from_domain]

args[:to] ||= args[:to_user] if args.has_key?(:to_user)
if args[:to]
Expand Down
9 changes: 9 additions & 0 deletions spec/sippy_cup/scenario_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
end
end

context "when a from_domain is specified" do
let(:args) { {from_domain: 'foo.bar'} }

it "includes the specified address in the From header" do
subject.invite
subject.to_xml.should match(%r{From: "sipp" <sip:sipp@foo.bar:\[local_port\]})
end
end

context "when no from user is specified" do
it "uses a default of 'sipp' in the From and Contact headers" do
subject.invite
Expand Down