-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for BasicAuth + alwaysSendBasicAuthHeaders in JsonService…
…Client
- Loading branch information
Showing
6 changed files
with
1,776 additions
and
1,430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/AndroidClient/client/src/test/java/net/servicestack/client/tests/TestAuthTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.servicestack.client.tests; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import net.servicestack.client.JsonServiceClient; | ||
import net.servicestack.client.WebServiceException; | ||
|
||
import net.servicestack.client.tests.testdtos.*; | ||
|
||
/** | ||
* Created by mythz on 1/3/2016. | ||
*/ | ||
public class TestAuthTests extends TestCase { | ||
|
||
JsonServiceClient client = new JsonServiceClient("http://test.servicestack.net"); | ||
|
||
public void test_AuthRequired_returns_401(){ | ||
try { | ||
client.get(new TestAuth()); | ||
fail("should throw"); | ||
} catch (WebServiceException ex){ | ||
assertEquals(401, ex.getStatusCode()); | ||
assertEquals("Unauthorized", ex.getStatusDescription()); | ||
} | ||
} | ||
|
||
public void test_does_send_BasicAuthHeaders(){ | ||
client.setCredentials("test", "test"); | ||
client.setAlwaysSendBasicAuthHeaders(true); | ||
|
||
TestAuthResponse response = client.get(new TestAuth()); | ||
|
||
assertEquals("1", response.getUserId()); | ||
assertEquals("test", response.getUserName()); | ||
assertEquals("test DisplayName", response.getDisplayName()); | ||
assertNotNull(response.getSessionId()); | ||
} | ||
} |
Oops, something went wrong.