Android Open Source - couchbase-lite-android Mock Facebook Auth Post






From Project

Back to project page couchbase-lite-android.

License

The source code is released under:

Apache License

If you think the Android project couchbase-lite-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.couchbase.lite.mockserver;
//  w w  w  . j  a v  a2 s .  c  o m
import com.squareup.okhttp.mockwebserver.MockResponse;

public class MockFacebookAuthPost {

    public MockResponse generateMockResponse() {
        MockResponse mockResponse = new MockResponse();
        String jsonBody = "{\n" +
                "   \"error\":\"Unauthorized\",\n" +
                "   \"reason\":\"Facebook verification server status 400\"\n" +
                "}";
        mockResponse.setBody(jsonBody);
        mockResponse.setStatus("HTTP/1.1 401 Unauthorized").setHeader("Content-Type", "application/json");
        return mockResponse;
    }

    public MockResponse generateMockResponseForSuccess(String email) {
        /**
         * Facebook actual response
         *
        HTTP/1.1 200 OK
        Date: Mon, 22 Dec 2014 22:16:31 GMT
        Content-Type: application/json
        Content-Length: 568
        Connection: keep-alive
        Server: Couchbase Sync Gateway/1.00
        Set-Cookie: SyncGatewaySession=015f9770ebe9968ae04306f591d38e12c1391886; Path=/todolite/; Expires=Tue, 23 Dec 2014 22:16:31 UTC

        {"authentication_handlers":["default","cookie"],"ok":true,"userCtx":{"channels":{"list-00F9B6FC-7B2C-47A8-9E4C-0855E1468A96":376,"list-07FB5332-7D6E-4B43-9C4B-A3C48F6548A4":57408,"list-0919487F-1D3D-41CE-88A0-C3F08BEFFF0D":381,"list-4290A9F4-0BCD-4C49-BEAF-4177B7585CD7":57507,"list-66ece56f-2422-4d4a-8858-583ddb665ec5":58528,"list-67C0AD63-6946-42AC-BF2A-3CAE7DCDD1C4":57761,"list-7E0A551D-13CC-4008-8749-125CC11E2F98":59284,"list-DF3A5540-8A99-4222-9C77-74D83DE2B8A6":428,"list-E5C26632-4E5A-46F0-9C97-C09698BF20D5":57801,"profiles":375},"name":"myfacebook@gmail.com"}}
         */
        MockResponse mockResponse = new MockResponse();
        String jsonBody = "{\"name\":\""+email+"\"}";
        mockResponse.setBody(jsonBody);
        mockResponse.setStatus("HTTP/1.1 200 OK").setHeader("Content-Type", "application/json");
        return mockResponse;
    }
}




Java Source Code List

com.couchbase.lite.ApiTest.java
com.couchbase.lite.AttachmentsTest.java
com.couchbase.lite.AuthTest.java
com.couchbase.lite.Base64Test.java
com.couchbase.lite.BlobStoreWriterTest.java
com.couchbase.lite.CRUDOperationsTest.java
com.couchbase.lite.CacheTest.java
com.couchbase.lite.ChangesTest.java
com.couchbase.lite.CollationTest.java
com.couchbase.lite.DatabaseTest.java
com.couchbase.lite.DocumentTest.java
com.couchbase.lite.LitePerfTestCase.java
com.couchbase.lite.LiteTestCase.java
com.couchbase.lite.LiteTestContext.java
com.couchbase.lite.LocalDocsTest.java
com.couchbase.lite.ManagerTest.java
com.couchbase.lite.MiscTest.java
com.couchbase.lite.MultipartReaderTest.java
com.couchbase.lite.RevTreeTest.java
com.couchbase.lite.RevisionsTest.java
com.couchbase.lite.RouterTest.java
com.couchbase.lite.SequenceMapTest.java
com.couchbase.lite.ValidationsTest.java
com.couchbase.lite.ViewsTest.java
com.couchbase.lite.android.AndroidContext.java
com.couchbase.lite.android.AndroidLogger.java
com.couchbase.lite.android.AndroidNetworkReachabilityManager.java
com.couchbase.lite.android.AndroidSQLiteStorageEngineFactory.java
com.couchbase.lite.android.AndroidSQLiteStorageEngine.java
com.couchbase.lite.mockserver.MockBulkDocs.java
com.couchbase.lite.mockserver.MockChangesFeedNoResponse.java
com.couchbase.lite.mockserver.MockChangesFeed.java
com.couchbase.lite.mockserver.MockCheckpointGet.java
com.couchbase.lite.mockserver.MockCheckpointPut.java
com.couchbase.lite.mockserver.MockDispatcher.java
com.couchbase.lite.mockserver.MockDocumentBulkGet.java
com.couchbase.lite.mockserver.MockDocumentGet.java
com.couchbase.lite.mockserver.MockDocumentPut.java
com.couchbase.lite.mockserver.MockFacebookAuthPost.java
com.couchbase.lite.mockserver.MockHelper.java
com.couchbase.lite.mockserver.MockPreloadedPullTarget.java
com.couchbase.lite.mockserver.MockRevsDiff.java
com.couchbase.lite.mockserver.MockSessionGet.java
com.couchbase.lite.mockserver.SmartMockResponse.java
com.couchbase.lite.mockserver.WrappedSmartMockResponse.java
com.couchbase.lite.performance2.Test01_CreateDocs.java
com.couchbase.lite.performance2.Test02_CreateDocsUnoptimizedWay.java
com.couchbase.lite.performance2.Test03_CreateDocsWithAttachments.java
com.couchbase.lite.performance2.Test06_PullReplication.java
com.couchbase.lite.performance2.Test07_PushReplication.java
com.couchbase.lite.performance2.Test08_DocRevisions.java
com.couchbase.lite.performance2.Test09_LoadDB.java
com.couchbase.lite.performance2.Test10_DeleteDB.java
com.couchbase.lite.performance2.Test11_DeleteDocs.java
com.couchbase.lite.performance2.Test12_IndexView.java
com.couchbase.lite.performance2.Test13_QueryView.java
com.couchbase.lite.performance2.Test14_ReduceView.java
com.couchbase.lite.performance2.Test28_KeySizes.java
com.couchbase.lite.performance2.Test29_AllDocQuery.java
com.couchbase.lite.performance2.Test30_LiveQuery.java
com.couchbase.lite.performance2.Test31_CompactDB.java
com.couchbase.lite.performance.Test10_DeleteDB.java
com.couchbase.lite.performance.Test11_DeleteDocs.java
com.couchbase.lite.performance.Test12_IndexView.java
com.couchbase.lite.performance.Test13_QueryView.java
com.couchbase.lite.performance.Test14_ReduceView.java
com.couchbase.lite.performance.Test16_ParallelPushReplication.java
com.couchbase.lite.performance.Test1_CreateDocs.java
com.couchbase.lite.performance.Test2_CreateDocsUnoptimizedWay.java
com.couchbase.lite.performance.Test3_CreateDocsWithAttachments.java
com.couchbase.lite.performance.Test6_PushReplication.java
com.couchbase.lite.performance.Test7_PullReplication.java
com.couchbase.lite.performance.Test8_DocRevisions.java
com.couchbase.lite.performance.Test9_LoadDB.java
com.couchbase.lite.replicator.BulkDownloaderTest.java
com.couchbase.lite.replicator.ChangeTrackerTest.java
com.couchbase.lite.replicator.CustomizableMockHttpClient.java
com.couchbase.lite.replicator.ReplicationTest.java
com.couchbase.lite.replicator.ResponderChain.java
com.couchbase.lite.support.BatcherTest.java
com.couchbase.lite.support.JsonDocumentTest.java
com.couchbase.lite.support.PersistentCookieStoreTest.java
com.couchbase.lite.support.RemoteRequestTest.java
com.couchbase.touchdb.RevCollator.java
com.couchbase.touchdb.TDCollateJSON.java