CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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