SIP account creation and reset

root21 created

Changed the SIP account creation and reset command to prepend a "c" in
front of the customer_id.

Change summary

lib/sip_account.rb    |  6 +++---
test/test_customer.rb | 14 +++++++-------
2 files changed, 10 insertions(+), 10 deletions(-)

Detailed changes

lib/sip_account.rb 🔗

@@ -8,11 +8,11 @@ require_relative "bandwidth_iris_patch"
 require_relative "mn_words"
 
 class SipAccount
-	def self.find(name)
-		new(BandwidthIris::SipCredential.get(name))
+	def self.find(customer_id)
+		new(BandwidthIris::SipCredential.get("c#{customer_id}"))
 	rescue BandwidthIris::APIError # 404
 		New.new(BandwidthIris::SipCredential.new(
-			user_name: name,
+			user_name: "c#{customer_id}",
 			realm: CONFIG[:sip][:realm],
 			http_voice_v2_app_id: CONFIG[:sip][:app]
 		))

test/test_customer.rb 🔗

@@ -195,7 +195,7 @@ class CustomerTest < Minitest::Test
 	def test_sip_account_new
 		req = stub_request(
 			:get,
-			"https://dashboard.bandwidth.com/v1.0/accounts//sipcredentials/test"
+			"https://dashboard.bandwidth.com/v1.0/accounts//sipcredentials/ctest"
 		).with(
 			headers: {
 				"Authorization" => "Basic Og=="
@@ -208,7 +208,7 @@ class CustomerTest < Minitest::Test
 		)
 		sip = customer.sip_account
 		assert_kind_of SipAccount::New, sip
-		assert_equal "test", sip.username
+		assert_equal "ctest", sip.username
 		assert_requested req
 	end
 	em :test_sip_account_new
@@ -216,21 +216,21 @@ class CustomerTest < Minitest::Test
 	def test_sip_account_existing
 		req1 = stub_request(
 			:get,
-			"https://dashboard.bandwidth.com/v1.0/accounts//sipcredentials/test"
+			"https://dashboard.bandwidth.com/v1.0/accounts//sipcredentials/ctest"
 		).with(
 			headers: {
 				"Authorization" => "Basic Og=="
 			}
 		).to_return(status: 200, body: {
 			SipCredential: {
-				UserName: "test",
+				UserName: "ctest",
 				Realm: "sip.example.com"
 			}
 		}.to_xml)
 
 		sip = customer.sip_account
 		assert_kind_of SipAccount, sip
-		assert_equal "test", sip.username
+		assert_equal "ctest", sip.username
 
 		assert_requested req1
 	end
@@ -239,7 +239,7 @@ class CustomerTest < Minitest::Test
 	def test_sip_account_error
 		stub_request(
 			:get,
-			"https://dashboard.bandwidth.com/v1.0/accounts//sipcredentials/test"
+			"https://dashboard.bandwidth.com/v1.0/accounts//sipcredentials/ctest"
 		).to_return(
 			status: 404,
 			body:
@@ -247,7 +247,7 @@ class CustomerTest < Minitest::Test
 				"<Description>desc</Description></ResponseStatus></r>"
 		)
 
-		assert_equal "test", customer.sip_account.username
+		assert_equal "ctest", customer.sip_account.username
 	end
 	em :test_sip_account_error