CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/lib/rex/proto/sms/client_spec.rb
Views: 1904
1
# -*- coding: binary -*-
2
require 'spec_helper'
3
4
RSpec.describe Rex::Proto::Sms::Client do
5
6
let(:phone_numbers) { ['1112223333'] }
7
8
let(:sms_subject) { 'subject' }
9
10
let(:message) { 'message' }
11
12
let(:carrier) { :verizon }
13
14
let(:smtp_server) {
15
Rex::Proto::Sms::Model::Smtp.new(
16
address: 'example.com',
17
port: 25,
18
username: 'username',
19
password: 'password'
20
)
21
}
22
23
subject do
24
Rex::Proto::Sms::Client.new(
25
carrier: carrier,
26
smtp_server: smtp_server
27
)
28
end
29
30
describe '#initialize' do
31
it 'sets carrier' do
32
expect(subject.carrier).to eq(carrier)
33
end
34
35
it 'sets smtp server' do
36
expect(subject.smtp_server).to eq(smtp_server)
37
end
38
end
39
40
describe '#send_text_to_phones' do
41
before(:each) do
42
smtp = Net::SMTP.new(smtp_server.address, smtp_server.port)
43
allow(smtp).to receive(:start).and_yield
44
allow(smtp).to receive(:send_message) { |args| @sent_message = args }
45
allow(Net::SMTP).to receive(:new).and_return(smtp)
46
end
47
48
it 'sends a text message' do
49
subject.send_text_to_phones(phone_numbers, sms_subject, message)
50
expect(@sent_message).to include(message)
51
end
52
end
53
54
end
55
56