@Test
public void finishRegistrationShouldDetectIncorrectClientDataOrigin() throws Exception {

    expectedException.expectCause(isA(U2fBadInputException.class));

    RegisterRequest registerRequest = new RegisterRequest(SERVER_CHALLENGE_REGISTER_BASE64, APP_ID_ENROLL);

    String clientDataBase64 = U2fB64Encoding.encode("{\"typ\":\"navigator.id.finishEnrollment\",\"challenge\":\"vqrS6WXDe1JUs5_c3i4-LkKIHRr-3XVb3azuA5TifHo\",\"origin\":\"http://evil.com\"}".getBytes("UTF-8"));

    u2f.finishRegistration(
        registerRequest,
        new RegisterResponse(
            TestVectors.REGISTRATION_DATA_BASE64,
            clientDataBase64
        )
    );

    fail("finishRegistration did not detect incorrect origin in client data");
}