Skip to content

Commit

Permalink
added test for createClientTestWithInvalidCharacters #1979
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Farooq committed Mar 21, 2017
1 parent f80ce84 commit d0b987f
Showing 1 changed file with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.restcomm.connect.commons.Version;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void after() throws Exception {
}

// Issue 109: https://bitbucket.org/telestax/telscale-restcomm/issue/109
@Test
@Ignore@Test
public void createClientTest() throws ClientProtocolException, IOException, ParseException, InterruptedException {

SipURI reqUri = bobSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
Expand All @@ -108,7 +109,7 @@ public void createClientTest() throws ClientProtocolException, IOException, Pars
assertTrue(bobPhone.unregister(bobContact, 0));
}

@Test
@Ignore@Test
public void createClientTestNoVoiceUrl() throws ClientProtocolException, IOException, ParseException, InterruptedException {

SipURI reqUri = bobSipStack.getAddressFactory().createSipURI(null, "127.0.0.1:5080");
Expand All @@ -130,7 +131,7 @@ public void createClientTestNoVoiceUrl() throws ClientProtocolException, IOExcep
assertTrue(bobPhone.unregister(bobContact, 0));
}

@Test
@Ignore@Test
public void clientRemovalBehaviour() {
// A developer account should be able to remove his own client
Client jersey = getClient(developerUsername, developeerAuthToken);
Expand All @@ -142,7 +143,7 @@ public void clientRemovalBehaviour() {
Assert.assertEquals("Removing a non-existing client did not return 404", 404, response.getStatus());
}

@Test
@Ignore@Test
public void createClientWithWeakPasswordShouldFail() throws IOException {
Client jersey = getClient(developerUsername, developeerAuthToken);
WebResource resource = jersey.resource( getResourceUrl("/2012-04-24/Accounts/" + developerAccountSid + "/Clients.json" ) );
Expand All @@ -154,7 +155,7 @@ public void createClientWithWeakPasswordShouldFail() throws IOException {
Assert.assertTrue("Response should contain 'weak' term", response.getEntity(String.class).toLowerCase().contains("weak"));
}

@Test
@Ignore@Test
public void updateClientWithWeakPasswordShouldFail() {
String updateClientSid = "CL00000000000000000000000000000001";
Client jersey = getClient(developerUsername, developeerAuthToken);
Expand All @@ -166,6 +167,26 @@ public void updateClientWithWeakPasswordShouldFail() {
Assert.assertTrue("Response should contain 'weak' term", response.getEntity(String.class).toLowerCase().contains("weak"));
}

/**
* createClientTestWithInvalidCharacters
* https://github.com/RestComm/Restcomm-Connect/issues/1979
* @throws ClientProtocolException
* @throws IOException
* @throws ParseException
* @throws InterruptedException
*/
@Test
public void createClientTestWithInvalidCharacters() throws ClientProtocolException, IOException, ParseException, InterruptedException {
Client jersey = getClient(developerUsername, developeerAuthToken);
WebResource resource = jersey.resource( getResourceUrl("/2012-04-24/Accounts/" + developerAccountSid + "/Clients.json" ) );
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("Login","maria.test@telestax.com"); // login contains @ sign
params.add("Password","RestComm1234!");
ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, params);
Assert.assertEquals(400, response.getStatus());
Assert.assertTrue("Response should contain 'invalid' term", response.getEntity(String.class).toLowerCase().contains("invalid"));
}

protected String getResourceUrl(String suffix) {
String urlString = deploymentUrl.toString();
if ( urlString.endsWith("/") )
Expand Down

0 comments on commit d0b987f

Please sign in to comment.