This commit is contained in:
Stephan 2018-12-21 12:28:56 +01:00
commit e51d1bfade
172 changed files with 49629 additions and 49629 deletions

View file

@ -1,16 +1,16 @@
from __future__ import unicode_literals
import sure # noqa
import moto.server as server
'''
Test the different server responses
'''
def test_ses_list_identities():
backend = server.create_backend_app("ses")
test_client = backend.test_client()
res = test_client.get('/?Action=ListIdentities')
res.data.should.contain(b"ListIdentitiesResponse")
from __future__ import unicode_literals
import sure # noqa
import moto.server as server
'''
Test the different server responses
'''
def test_ses_list_identities():
backend = server.create_backend_app("ses")
test_client = backend.test_client()
res = test_client.get('/?Action=ListIdentities')
res.data.should.contain(b"ListIdentitiesResponse")

View file

@ -1,116 +1,116 @@
from __future__ import unicode_literals
import email
import boto
from boto.exception import BotoServerError
import sure # noqa
from moto import mock_ses_deprecated
@mock_ses_deprecated
def test_verify_email_identity():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_email_identity("test@example.com")
identities = conn.list_identities()
address = identities['ListIdentitiesResponse'][
'ListIdentitiesResult']['Identities'][0]
address.should.equal('test@example.com')
@mock_ses_deprecated
def test_domain_verify():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_domain_dkim("domain1.com")
conn.verify_domain_identity("domain2.com")
identities = conn.list_identities()
domains = list(identities['ListIdentitiesResponse'][
'ListIdentitiesResult']['Identities'])
domains.should.equal(['domain1.com', 'domain2.com'])
@mock_ses_deprecated
def test_delete_identity():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_email_identity("test@example.com")
conn.list_identities()['ListIdentitiesResponse']['ListIdentitiesResult'][
'Identities'].should.have.length_of(1)
conn.delete_identity("test@example.com")
conn.list_identities()['ListIdentitiesResponse']['ListIdentitiesResult'][
'Identities'].should.have.length_of(0)
@mock_ses_deprecated
def test_send_email():
conn = boto.connect_ses('the_key', 'the_secret')
conn.send_email.when.called_with(
"test@example.com", "test subject",
"test body", "test_to@example.com").should.throw(BotoServerError)
conn.verify_email_identity("test@example.com")
conn.send_email("test@example.com", "test subject",
"test body", "test_to@example.com")
send_quota = conn.get_send_quota()
sent_count = int(send_quota['GetSendQuotaResponse'][
'GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses_deprecated
def test_send_html_email():
conn = boto.connect_ses('the_key', 'the_secret')
conn.send_email.when.called_with(
"test@example.com", "test subject",
"<span>test body</span>", "test_to@example.com", format="html").should.throw(BotoServerError)
conn.verify_email_identity("test@example.com")
conn.send_email("test@example.com", "test subject",
"<span>test body</span>", "test_to@example.com", format="html")
send_quota = conn.get_send_quota()
sent_count = int(send_quota['GetSendQuotaResponse'][
'GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses_deprecated
def test_send_raw_email():
conn = boto.connect_ses('the_key', 'the_secret')
message = email.mime.multipart.MIMEMultipart()
message['Subject'] = 'Test'
message['From'] = 'test@example.com'
message['To'] = 'to@example.com'
# Message body
part = email.mime.text.MIMEText('test file attached')
message.attach(part)
# Attachment
part = email.mime.text.MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
conn.send_raw_email.when.called_with(
source=message['From'],
raw_message=message.as_string(),
).should.throw(BotoServerError)
conn.verify_email_identity("test@example.com")
conn.send_raw_email(
source=message['From'],
raw_message=message.as_string(),
)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['GetSendQuotaResponse'][
'GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
from __future__ import unicode_literals
import email
import boto
from boto.exception import BotoServerError
import sure # noqa
from moto import mock_ses_deprecated
@mock_ses_deprecated
def test_verify_email_identity():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_email_identity("test@example.com")
identities = conn.list_identities()
address = identities['ListIdentitiesResponse'][
'ListIdentitiesResult']['Identities'][0]
address.should.equal('test@example.com')
@mock_ses_deprecated
def test_domain_verify():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_domain_dkim("domain1.com")
conn.verify_domain_identity("domain2.com")
identities = conn.list_identities()
domains = list(identities['ListIdentitiesResponse'][
'ListIdentitiesResult']['Identities'])
domains.should.equal(['domain1.com', 'domain2.com'])
@mock_ses_deprecated
def test_delete_identity():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_email_identity("test@example.com")
conn.list_identities()['ListIdentitiesResponse']['ListIdentitiesResult'][
'Identities'].should.have.length_of(1)
conn.delete_identity("test@example.com")
conn.list_identities()['ListIdentitiesResponse']['ListIdentitiesResult'][
'Identities'].should.have.length_of(0)
@mock_ses_deprecated
def test_send_email():
conn = boto.connect_ses('the_key', 'the_secret')
conn.send_email.when.called_with(
"test@example.com", "test subject",
"test body", "test_to@example.com").should.throw(BotoServerError)
conn.verify_email_identity("test@example.com")
conn.send_email("test@example.com", "test subject",
"test body", "test_to@example.com")
send_quota = conn.get_send_quota()
sent_count = int(send_quota['GetSendQuotaResponse'][
'GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses_deprecated
def test_send_html_email():
conn = boto.connect_ses('the_key', 'the_secret')
conn.send_email.when.called_with(
"test@example.com", "test subject",
"<span>test body</span>", "test_to@example.com", format="html").should.throw(BotoServerError)
conn.verify_email_identity("test@example.com")
conn.send_email("test@example.com", "test subject",
"<span>test body</span>", "test_to@example.com", format="html")
send_quota = conn.get_send_quota()
sent_count = int(send_quota['GetSendQuotaResponse'][
'GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses_deprecated
def test_send_raw_email():
conn = boto.connect_ses('the_key', 'the_secret')
message = email.mime.multipart.MIMEMultipart()
message['Subject'] = 'Test'
message['From'] = 'test@example.com'
message['To'] = 'to@example.com'
# Message body
part = email.mime.text.MIMEText('test file attached')
message.attach(part)
# Attachment
part = email.mime.text.MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
conn.send_raw_email.when.called_with(
source=message['From'],
raw_message=message.as_string(),
).should.throw(BotoServerError)
conn.verify_email_identity("test@example.com")
conn.send_raw_email(
source=message['From'],
raw_message=message.as_string(),
)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['GetSendQuotaResponse'][
'GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)

View file

@ -1,194 +1,194 @@
from __future__ import unicode_literals
import boto3
from botocore.exceptions import ClientError
from six.moves.email_mime_multipart import MIMEMultipart
from six.moves.email_mime_text import MIMEText
import sure # noqa
from moto import mock_ses
@mock_ses
def test_verify_email_identity():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_email_identity(EmailAddress="test@example.com")
identities = conn.list_identities()
address = identities['Identities'][0]
address.should.equal('test@example.com')
@mock_ses
def test_verify_email_address():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_email_address(EmailAddress="test@example.com")
email_addresses = conn.list_verified_email_addresses()
email = email_addresses['VerifiedEmailAddresses'][0]
email.should.equal('test@example.com')
@mock_ses
def test_domain_verify():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_domain_dkim(Domain="domain1.com")
conn.verify_domain_identity(Domain="domain2.com")
identities = conn.list_identities()
domains = list(identities['Identities'])
domains.should.equal(['domain1.com', 'domain2.com'])
@mock_ses
def test_delete_identity():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_email_identity(EmailAddress="test@example.com")
conn.list_identities()['Identities'].should.have.length_of(1)
conn.delete_identity(Identity="test@example.com")
conn.list_identities()['Identities'].should.have.length_of(0)
@mock_ses
def test_send_email():
conn = boto3.client('ses', region_name='us-east-1')
kwargs = dict(
Source="test@example.com",
Destination={
"ToAddresses": ["test_to@example.com"],
"CcAddresses": ["test_cc@example.com"],
"BccAddresses": ["test_bcc@example.com"],
},
Message={
"Subject": {"Data": "test subject"},
"Body": {"Text": {"Data": "test body"}}
}
)
conn.send_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_domain_identity(Domain='example.com')
conn.send_email(**kwargs)
too_many_addresses = list('to%s@example.com' % i for i in range(51))
conn.send_email.when.called_with(
**dict(kwargs, Destination={'ToAddresses': too_many_addresses})
).should.throw(ClientError)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(3)
@mock_ses
def test_send_html_email():
conn = boto3.client('ses', region_name='us-east-1')
kwargs = dict(
Source="test@example.com",
Destination={
"ToAddresses": ["test_to@example.com"]
},
Message={
"Subject": {"Data": "test subject"},
"Body": {"Html": {"Data": "test body"}}
}
)
conn.send_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_email_identity(EmailAddress="test@example.com")
conn.send_email(**kwargs)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses
def test_send_raw_email():
conn = boto3.client('ses', region_name='us-east-1')
message = MIMEMultipart()
message['Subject'] = 'Test'
message['From'] = 'test@example.com'
message['To'] = 'to@example.com, foo@example.com'
# Message body
part = MIMEText('test file attached')
message.attach(part)
# Attachment
part = MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
kwargs = dict(
Source=message['From'],
RawMessage={'Data': message.as_string()},
)
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_email_identity(EmailAddress="test@example.com")
conn.send_raw_email(**kwargs)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(2)
@mock_ses
def test_send_raw_email_without_source():
conn = boto3.client('ses', region_name='us-east-1')
message = MIMEMultipart()
message['Subject'] = 'Test'
message['From'] = 'test@example.com'
message['To'] = 'to@example.com, foo@example.com'
# Message body
part = MIMEText('test file attached')
message.attach(part)
# Attachment
part = MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
kwargs = dict(
RawMessage={'Data': message.as_string()},
)
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_email_identity(EmailAddress="test@example.com")
conn.send_raw_email(**kwargs)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(2)
@mock_ses
def test_send_raw_email_without_source_or_from():
conn = boto3.client('ses', region_name='us-east-1')
message = MIMEMultipart()
message['Subject'] = 'Test'
message['To'] = 'to@example.com, foo@example.com'
# Message body
part = MIMEText('test file attached')
message.attach(part)
# Attachment
part = MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
kwargs = dict(
RawMessage={'Data': message.as_string()},
)
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
from __future__ import unicode_literals
import boto3
from botocore.exceptions import ClientError
from six.moves.email_mime_multipart import MIMEMultipart
from six.moves.email_mime_text import MIMEText
import sure # noqa
from moto import mock_ses
@mock_ses
def test_verify_email_identity():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_email_identity(EmailAddress="test@example.com")
identities = conn.list_identities()
address = identities['Identities'][0]
address.should.equal('test@example.com')
@mock_ses
def test_verify_email_address():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_email_address(EmailAddress="test@example.com")
email_addresses = conn.list_verified_email_addresses()
email = email_addresses['VerifiedEmailAddresses'][0]
email.should.equal('test@example.com')
@mock_ses
def test_domain_verify():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_domain_dkim(Domain="domain1.com")
conn.verify_domain_identity(Domain="domain2.com")
identities = conn.list_identities()
domains = list(identities['Identities'])
domains.should.equal(['domain1.com', 'domain2.com'])
@mock_ses
def test_delete_identity():
conn = boto3.client('ses', region_name='us-east-1')
conn.verify_email_identity(EmailAddress="test@example.com")
conn.list_identities()['Identities'].should.have.length_of(1)
conn.delete_identity(Identity="test@example.com")
conn.list_identities()['Identities'].should.have.length_of(0)
@mock_ses
def test_send_email():
conn = boto3.client('ses', region_name='us-east-1')
kwargs = dict(
Source="test@example.com",
Destination={
"ToAddresses": ["test_to@example.com"],
"CcAddresses": ["test_cc@example.com"],
"BccAddresses": ["test_bcc@example.com"],
},
Message={
"Subject": {"Data": "test subject"},
"Body": {"Text": {"Data": "test body"}}
}
)
conn.send_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_domain_identity(Domain='example.com')
conn.send_email(**kwargs)
too_many_addresses = list('to%s@example.com' % i for i in range(51))
conn.send_email.when.called_with(
**dict(kwargs, Destination={'ToAddresses': too_many_addresses})
).should.throw(ClientError)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(3)
@mock_ses
def test_send_html_email():
conn = boto3.client('ses', region_name='us-east-1')
kwargs = dict(
Source="test@example.com",
Destination={
"ToAddresses": ["test_to@example.com"]
},
Message={
"Subject": {"Data": "test subject"},
"Body": {"Html": {"Data": "test body"}}
}
)
conn.send_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_email_identity(EmailAddress="test@example.com")
conn.send_email(**kwargs)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses
def test_send_raw_email():
conn = boto3.client('ses', region_name='us-east-1')
message = MIMEMultipart()
message['Subject'] = 'Test'
message['From'] = 'test@example.com'
message['To'] = 'to@example.com, foo@example.com'
# Message body
part = MIMEText('test file attached')
message.attach(part)
# Attachment
part = MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
kwargs = dict(
Source=message['From'],
RawMessage={'Data': message.as_string()},
)
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_email_identity(EmailAddress="test@example.com")
conn.send_raw_email(**kwargs)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(2)
@mock_ses
def test_send_raw_email_without_source():
conn = boto3.client('ses', region_name='us-east-1')
message = MIMEMultipart()
message['Subject'] = 'Test'
message['From'] = 'test@example.com'
message['To'] = 'to@example.com, foo@example.com'
# Message body
part = MIMEText('test file attached')
message.attach(part)
# Attachment
part = MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
kwargs = dict(
RawMessage={'Data': message.as_string()},
)
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)
conn.verify_email_identity(EmailAddress="test@example.com")
conn.send_raw_email(**kwargs)
send_quota = conn.get_send_quota()
sent_count = int(send_quota['SentLast24Hours'])
sent_count.should.equal(2)
@mock_ses
def test_send_raw_email_without_source_or_from():
conn = boto3.client('ses', region_name='us-east-1')
message = MIMEMultipart()
message['Subject'] = 'Test'
message['To'] = 'to@example.com, foo@example.com'
# Message body
part = MIMEText('test file attached')
message.attach(part)
# Attachment
part = MIMEText('contents of test file here')
part.add_header('Content-Disposition', 'attachment; filename=test.txt')
message.attach(part)
kwargs = dict(
RawMessage={'Data': message.as_string()},
)
conn.send_raw_email.when.called_with(**kwargs).should.throw(ClientError)