diff --git a/CHANGELOG.md b/CHANGELOG.md index 87bea8e..8062c20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # develop + * Feature: added the ability to pass :remote_sip_address to #invite, a remote address to use in place of the SIPp constructed one # [0.6.0](https://github.com/mojolingo/sippy_cup/compare/v0.5.0...v0.6.0) * Change: Call limits (`number_of_calls`, `concurrent_max` and `calls_per_second`) no longer have default values for simplicity of UAS scenarios. The value of `to_user` now defaults to the SIPp default of `s`. diff --git a/lib/sippy_cup/scenario.rb b/lib/sippy_cup/scenario.rb index dd458f0..d90d902 100644 --- a/lib/sippy_cup/scenario.rb +++ b/lib/sippy_cup/scenario.rb @@ -149,13 +149,14 @@ def build(steps) # @param [Hash] opts A set of options to modify the message # @option opts [Integer] :retrans # @option opts [String] :headers Extra headers to place into the INVITE + # @option opts [String] :remote_sip_address Remote address to use in place of the SIPp constructed one # 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]" - to_addr = "[service]@[remote_ip]:[remote_port]" + to_addr = opts.delete(:remote_sip_address) || "[service]@[remote_ip]:[remote_port]" msg = <<-MSG INVITE sip:#{to_addr} SIP/2.0 @@ -325,7 +326,7 @@ def send_answer(opts = {}) Content-Length: [len] v=0 -o=user1 53655765 2353687637 IN IP[local_ip_type] #{@adv_ip} +o=user1 53655765 2353687637 IN IP[local_ip_type] #{@adv_ip} s=- c=IN IP[media_ip_type] [media_ip] t=0 0 diff --git a/spec/sippy_cup/scenario_spec.rb b/spec/sippy_cup/scenario_spec.rb index 9bf23e8..77f3613 100644 --- a/spec/sippy_cup/scenario_spec.rb +++ b/spec/sippy_cup/scenario_spec.rb @@ -91,6 +91,13 @@ subject.to_xml.should match(%r{Contact: }) + end + end end describe "#register" do