Package tests

Source Code of tests.AuthRestTest

package tests;

import org.stringtree.mojasef.local.LocalRequest;

public class AuthRestTest extends LocalRestTestCase {

    public AuthRestTest() {
        super("src/test/files/authrest/http.spec", "src/test/expected/authrest/");
    }

    public void testGetPublicUnknown() {
        request = new LocalRequest("public/12344");
        callAndCheckXML(request, "item12344");
    }

    public void testGetPublicKnown() {
        request = new LocalRequest("public/12345");
        callAndCheckXML(request, "item12345");
    }

    public void testGetPrivateUnknown() {
        request = new LocalRequest("private/12344");
        callAndCheckCode(request, "404");
    }

    public void testGetPrivateKnownButUnauthenticated() {
        request = new LocalRequest("private/12345");
        request.put("Authorization", "Basic 12345:1112");
        callAndCheckCode(request, "401");
        assertEquals("Basic realm=\"private:12345\"", response.get("WWW-Authenticate"));
    }

    public void testGetPrivateKnownButWrongPIN() {
        request = new LocalRequest("private/12345");
        callAndCheckCode(request, "401");
        assertEquals("Basic realm=\"private:12345\"", response.get("WWW-Authenticate"));
    }

    public void testGetPrivateKnownAndAuthenticated() {
        request = new LocalRequest("private/12345");
        request.put("Authorization", "Basic 12345:1111");
        callAndCheckXML(request, "item12345");
    }

    public void testGetPrivateIdUnknown() {
        request = new LocalRequest("id/12344/details");
        callAndCheckCode(request, "404");
    }

    public void testGetPrivateIdKnownButUnauthenticated() {
        request = new LocalRequest("id/12345/details");
        request.put("Authorization", "Basic 12345:1112");
        callAndCheckCode(request, "401");
        assertEquals("Basic realm=\"id:12345\"", response.get("WWW-Authenticate"));
    }

    public void testGetPrivateIdKnownButWrongPIN() {
        request = new LocalRequest("id/12345/details");
        callAndCheckCode(request, "401");
        assertEquals("Basic realm=\"id:12345\"", response.get("WWW-Authenticate"));
    }

    public void testGetPrivateIdKnownAndAuthenticated() {
        request = new LocalRequest("id/12345/details");
        request.put("Authorization", "Basic 12345:1111");
        callAndCheckXML(request, "item12345");
    }
}
TOP

Related Classes of tests.AuthRestTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.