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/model/message_spec.rb
Views: 11791
1
require 'spec_helper'
2
3
RSpec.describe Rex::Proto::Mms::Model::Message do
4
5
let(:message) { 'message' }
6
let(:content_type) { 'ctype' }
7
let(:attachment) { 'filepath.jpg' }
8
let(:filecontent) { 'file content' }
9
let(:from) { '[email protected]' }
10
let(:to) { '[email protected]' }
11
let(:mms_subject) { 'subject' }
12
13
before(:each) do
14
allow(File).to receive(:read).and_return(filecontent)
15
end
16
17
subject do
18
described_class.new(
19
from: from,
20
to: to,
21
subject: mms_subject,
22
message: message,
23
content_type: content_type,
24
attachment_path: attachment
25
)
26
end
27
28
describe '#initialize' do
29
it 'sets message' do
30
expect(subject.message).to eq(message)
31
end
32
33
it 'sets content type' do
34
expect(subject.content_type).to eq(content_type)
35
end
36
37
it 'sets attachment path' do
38
expect(subject.attachment).to eq('ZmlsZSBjb250ZW50')
39
end
40
41
it 'sets from' do
42
expect(subject.from).to eq(from)
43
end
44
45
it 'sets to' do
46
expect(subject.to).to eq(to)
47
end
48
49
it 'sets subject' do
50
expect(subject.subject).to eq(mms_subject)
51
end
52
end
53
54
describe '#to_s' do
55
it 'returns the mms message' do
56
expect(subject.to_s).to include('MIME-Version: 1.0')
57
58
end
59
end
60
61
end
62
63