@@ -0,0 +1,3424 @@
+/*%0A * Copyright 2017, OnGres.%0A *%0A * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the%0A * following conditions are met:%0A *%0A * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following%0A * disclaimer.%0A *%0A * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the%0A * following disclaimer in the documentation and/or other materials provided with the distribution.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES,%0A * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE%0A * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR%0A * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,%0A * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A *%0A */%0A%0A%0Apackage com.ongres.scram.common.message;%0A%0A%0Aimport com.ongres.scram.common.ScramAttributes;%0Aimport com.ongres.scram.common.ScramFunctions;%0Aimport com.ongres.scram.common.ScramMechanisms;%0Aimport com.ongres.scram.common.stringprep.StringPreparations;%0Aimport org.junit.Test;%0A%0Aimport java.util.Base64;%0A%0Aimport static com.ongres.scram.common.RfcExample.*;%0Aimport static junit.framework.TestCase.assertFalse;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0A%0Apublic class ServerFinalMessageTest %7B%0A    @Test%0A    public void validConstructor() %7B%0A        byte%5B%5D serverKey = ScramFunctions.serverKey(%0A                ScramMechanisms.SCRAM_SHA_1,%0A                StringPreparations.NO_PREPARATION,%0A                PASSWORD,%0A                Base64.getDecoder().decode(SERVER_SALT),%0A                SERVER_ITERATIONS%0A        );%0A        ServerFinalMessage serverFinalMessage1 = new ServerFinalMessage(%0A                ScramFunctions.serverSignature(ScramMechanisms.SCRAM_SHA_1, serverKey, AUTH_MESSAGE)%0A        );%0A        assertEquals(SERVER_FINAL_MESSAGE, serverFinalMessage1.toString());%0A        assertFalse(serverFinalMessage1.isError());%0A%0A        ServerFinalMessage serverFinalMessage2 = new ServerFinalMessage(ServerFinalMessage.Error.UNKNOWN_USER);%0A        assertEquals(ScramAttributes.ERROR.getChar() + %22=%22 + %22unknown-user%22, serverFinalMessage2.toString());%0A        assertTrue(serverFinalMessage2.isError());%0A    %7D%0A%0A    @Test%0A    public void validParseFrom() %7B%0A        ServerFinalMessage serverFinalMessage1 = ServerFinalMessage.parseFrom(SERVER_FINAL_MESSAGE);%0A        assertEquals(SERVER_FINAL_MESSAGE, serverFinalMessage1.toString());%0A        assertFalse(serverFinalMessage1.isError());%0A%0A        ServerFinalMessage serverFinalMessage2 = ServerFinalMessage.parseFrom(%22e=channel-binding-not-supported%22);%0A        assertEquals(%22e=channel-binding-not-supported%22, serverFinalMessage2.toString());%0A        assertTrue(serverFinalMessage2.isError());%0A        assertTrue(serverFinalMessage2.getError().get() == ServerFinalMessage.Error.CHANNEL_BINDING_NOT_SUPPORTED);%0A    %7D%0A%7D%0A

Add tests for server-final-message