/** * https://jira.spring.io/browse/SPR-2866 */ @Test public void passwordValueIsNotRenderedByDefault() throws Exception { this.getTag().setPath("name"); assertEquals(Tag.SKIP_BODY, this.getTag().doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", getType()); assertValueAttribute(output, ""); }
private PasswordInputTag getPasswordTag() { return (PasswordInputTag) this.getTag(); }
@Override protected void assertValueAttribute(String output, String expectedValue) { if (this.getPasswordTag().isShowPassword()) { super.assertValueAttribute(output, expectedValue); } else { super.assertValueAttribute(output, ""); } }
@Test @Override public void dynamicTypeAttribute() throws JspException { try { this.getTag().setDynamicAttribute(null, "type", "email"); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("Attribute type=\"email\" is not allowed", e.getMessage()); } }
/** * https://jira.spring.io/browse/SPR-2866 */ @Test public void passwordValueIsNotRenderedIfShowPasswordAttributeIsSetToFalse() throws Exception { this.getTag().setPath("name"); this.getPasswordTag().setShowPassword(false); assertEquals(Tag.SKIP_BODY, this.getTag().doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", getType()); assertValueAttribute(output, ""); }
/** * https://jira.spring.io/browse/SPR-2866 */ @Test public void passwordValueIsRenderedIfShowPasswordAttributeIsSetToTrue() throws Exception { this.getTag().setPath("name"); this.getPasswordTag().setShowPassword(true); assertEquals(Tag.SKIP_BODY, this.getTag().doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", getType()); assertValueAttribute(output, "Rob"); }