Code example for PasswordCallback

Methods: getPassword, getPrompt

0
        PasswordCallback convertedPasswordCallback = restAuthPasswordCallbackHandler.convertFromJson(passwordCallback,
                jsonPasswordCallback);
 
        //Then 
        Assert.assertEquals(passwordCallback, convertedPasswordCallback);
        Assert.assertEquals("Enter password:", convertedPasswordCallback.getPrompt());
        Assert.assertEquals("PASSWORD", new String(convertedPasswordCallback.getPassword()));
    } 
 
    @Test (expectedExceptions = RestAuthException.class) 
    public void shouldFailToConvertFromJsonWithInvalidType() throws JSONException { 
 
        //Given 
        PasswordCallback passwordCallback = new PasswordCallback("Enter password:", false);
        JSONObject jsonPasswordCallback = new JSONObject()
                .put("input", new JSONArray().put(
                        new JSONObject()
                                .put("value", "PASSWORD")))
                .put("output", new JSONArray().put(
                        new JSONObject()
                                .put("value", "Enter password:")))