Merge pull request #66 from doom369/master

#65 Added AccountBuilder.addEmail method
pull/68/head
Richard Körber 2018-07-29 16:39:14 +02:00 committed by GitHub
commit acfb2d315d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

View File

@ -303,6 +303,21 @@ public class Account extends AcmeJsonResource {
return this;
}
/**
* Adds a new Contact email to the account.
* <p>
* This is a convenience call for {@link #addContact(String)} hat doesn't
* require from you attach "mailto" scheme before email address.
*
* @param email
* Contact email without "mailto" scheme (e.g. test@gmail.com)
* @return itself
*/
public EditableAccount addEmail(String email) {
addContact("mailto:" + email);
return this;
}
/**
* Commits the changes and updates the account.
*/

View File

@ -84,6 +84,23 @@ public class AccountBuilder {
return this;
}
/**
* Add a email address to the list of contacts.
* <p>
* This is a convenience call for {@link #addContact(String)} that doesn't
* require from you attach "mailto" scheme before email address.
*
* @param email
* Contact email without "mailto" scheme (e.g. test@gmail.com)
* @throws IllegalArgumentException
* if there is a syntax error in the URI string
* @return itself
*/
public AccountBuilder addEmail(String email) {
addContact("mailto:" + email);
return this;
}
/**
* Signals that the user agrees to the terms of service.
*

View File

@ -28,6 +28,7 @@ import org.jose4j.jws.JsonWebSignature;
import org.jose4j.jwx.CompactSerializer;
import org.jose4j.lang.JoseException;
import org.junit.Test;
import org.mockito.Mockito;
import org.shredzone.acme4j.connector.Resource;
import org.shredzone.acme4j.provider.TestableConnectionProvider;
import org.shredzone.acme4j.toolbox.AcmeUtils;
@ -220,4 +221,10 @@ public class AccountBuilderTest {
provider.close();
}
@Test
public void testEmailAddresses() {
AccountBuilder builder = Mockito.spy(AccountBuilder.class);
builder.addEmail("foo@example.com");
Mockito.verify(builder).addContact(Mockito.eq("mailto:foo@example.com"));
}
}