Adding list_verified_email_addresses and testing
This commit is contained in:
		
							parent
							
								
									28b1d99100
								
							
						
					
					
						commit
						2a65f40a19
					
				@ -36,6 +36,7 @@ class SESBackend(BaseBackend):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __init__(self):
 | 
					    def __init__(self):
 | 
				
			||||||
        self.addresses = []
 | 
					        self.addresses = []
 | 
				
			||||||
 | 
					        self.email_addresses = []
 | 
				
			||||||
        self.domains = []
 | 
					        self.domains = []
 | 
				
			||||||
        self.sent_messages = []
 | 
					        self.sent_messages = []
 | 
				
			||||||
        self.sent_message_count = 0
 | 
					        self.sent_message_count = 0
 | 
				
			||||||
@ -49,12 +50,18 @@ class SESBackend(BaseBackend):
 | 
				
			|||||||
    def verify_email_identity(self, address):
 | 
					    def verify_email_identity(self, address):
 | 
				
			||||||
        self.addresses.append(address)
 | 
					        self.addresses.append(address)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def verify_email_address(self, address):
 | 
				
			||||||
 | 
					        self.email_addresses.append(address)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def verify_domain(self, domain):
 | 
					    def verify_domain(self, domain):
 | 
				
			||||||
        self.domains.append(domain)
 | 
					        self.domains.append(domain)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def list_identities(self):
 | 
					    def list_identities(self):
 | 
				
			||||||
        return self.domains + self.addresses
 | 
					        return self.domains + self.addresses
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def list_verified_email_addresses(self):
 | 
				
			||||||
 | 
					        return self.email_addresses
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def delete_identity(self, identity):
 | 
					    def delete_identity(self, identity):
 | 
				
			||||||
        if '@' in identity:
 | 
					        if '@' in identity:
 | 
				
			||||||
            self.addresses.remove(identity)
 | 
					            self.addresses.remove(identity)
 | 
				
			||||||
 | 
				
			|||||||
@ -15,11 +15,22 @@ class EmailResponse(BaseResponse):
 | 
				
			|||||||
        template = self.response_template(VERIFY_EMAIL_IDENTITY)
 | 
					        template = self.response_template(VERIFY_EMAIL_IDENTITY)
 | 
				
			||||||
        return template.render()
 | 
					        return template.render()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def verify_email_address(self):
 | 
				
			||||||
 | 
					        address = self.querystring.get('EmailAddress')[0]
 | 
				
			||||||
 | 
					        ses_backend.verify_email_address(address)
 | 
				
			||||||
 | 
					        template = self.response_template(VERIFY_EMAIL_ADDRESS)
 | 
				
			||||||
 | 
					        return template.render()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def list_identities(self):
 | 
					    def list_identities(self):
 | 
				
			||||||
        identities = ses_backend.list_identities()
 | 
					        identities = ses_backend.list_identities()
 | 
				
			||||||
        template = self.response_template(LIST_IDENTITIES_RESPONSE)
 | 
					        template = self.response_template(LIST_IDENTITIES_RESPONSE)
 | 
				
			||||||
        return template.render(identities=identities)
 | 
					        return template.render(identities=identities)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def list_verified_email_addresses(self):
 | 
				
			||||||
 | 
					        email_addresses = ses_backend.list_verified_email_addresses()
 | 
				
			||||||
 | 
					        template = self.response_template(LIST_VERIFIED_EMAIL_RESPONSE)
 | 
				
			||||||
 | 
					        return template.render(email_addresses=email_addresses)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def verify_domain_dkim(self):
 | 
					    def verify_domain_dkim(self):
 | 
				
			||||||
        domain = self.querystring.get('Domain')[0]
 | 
					        domain = self.querystring.get('Domain')[0]
 | 
				
			||||||
        ses_backend.verify_domain(domain)
 | 
					        ses_backend.verify_domain(domain)
 | 
				
			||||||
@ -95,6 +106,13 @@ VERIFY_EMAIL_IDENTITY = """<VerifyEmailIdentityResponse xmlns="http://ses.amazon
 | 
				
			|||||||
  </ResponseMetadata>
 | 
					  </ResponseMetadata>
 | 
				
			||||||
</VerifyEmailIdentityResponse>"""
 | 
					</VerifyEmailIdentityResponse>"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					VERIFY_EMAIL_ADDRESS = """<VerifyEmailAddressResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
 | 
				
			||||||
 | 
					  <VerifyEmailAddressResult/>
 | 
				
			||||||
 | 
					  <ResponseMetadata>
 | 
				
			||||||
 | 
					    <RequestId>47e0ef1a-9bf2-11e1-9279-0100e8cf109a</RequestId>
 | 
				
			||||||
 | 
					  </ResponseMetadata>
 | 
				
			||||||
 | 
					</VerifyEmailAddressResponse>"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
LIST_IDENTITIES_RESPONSE = """<ListIdentitiesResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
 | 
					LIST_IDENTITIES_RESPONSE = """<ListIdentitiesResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
 | 
				
			||||||
  <ListIdentitiesResult>
 | 
					  <ListIdentitiesResult>
 | 
				
			||||||
    <Identities>
 | 
					    <Identities>
 | 
				
			||||||
@ -108,6 +126,19 @@ LIST_IDENTITIES_RESPONSE = """<ListIdentitiesResponse xmlns="http://ses.amazonaw
 | 
				
			|||||||
  </ResponseMetadata>
 | 
					  </ResponseMetadata>
 | 
				
			||||||
</ListIdentitiesResponse>"""
 | 
					</ListIdentitiesResponse>"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					LIST_VERIFIED_EMAIL_RESPONSE = """<ListVerifiedEmailAddressesResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
 | 
				
			||||||
 | 
					  <ListVerifiedEmailAddressesResult>
 | 
				
			||||||
 | 
					    <VerifiedEmailAddresses>
 | 
				
			||||||
 | 
					        {% for email in email_addresses %}
 | 
				
			||||||
 | 
					          <member>{{ email }}</member>
 | 
				
			||||||
 | 
					        {% endfor %}
 | 
				
			||||||
 | 
					    </VerifiedEmailAddresses>
 | 
				
			||||||
 | 
					  </ListVerifiedEmailAddressesResult>
 | 
				
			||||||
 | 
					  <ResponseMetadata>
 | 
				
			||||||
 | 
					    <RequestId>cacecf23-9bf1-11e1-9279-0100e8cf109a</RequestId>
 | 
				
			||||||
 | 
					  </ResponseMetadata>
 | 
				
			||||||
 | 
					</ListVerifiedEmailAddressesResponse>"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VERIFY_DOMAIN_DKIM_RESPONSE = """<VerifyDomainDkimResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
 | 
					VERIFY_DOMAIN_DKIM_RESPONSE = """<VerifyDomainDkimResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
 | 
				
			||||||
  <VerifyDomainDkimResult>
 | 
					  <VerifyDomainDkimResult>
 | 
				
			||||||
    <DkimTokens>
 | 
					    <DkimTokens>
 | 
				
			||||||
 | 
				
			|||||||
@ -19,6 +19,13 @@ def test_verify_email_identity():
 | 
				
			|||||||
    address = identities['Identities'][0]
 | 
					    address = identities['Identities'][0]
 | 
				
			||||||
    address.should.equal('test@example.com')
 | 
					    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
 | 
					@mock_ses
 | 
				
			||||||
def test_domain_verify():
 | 
					def test_domain_verify():
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user