@Test void toProperties_ServerConfig_empty() { Map<String, String> props = ConfigPropertiesUtil.toProperties( ServerConfig.createFrom( new MockConfigPart() .withUsername("username") .withServerName("servername") ), "<unset>", "<stored>", "<ns>" ); assertThat(props, mapContainsAll( new Pair<>("P4PORT", portName("servername")), new Pair<>("P4USER", "username"), new Pair<>("P4PASSWD", "<ns>"), new Pair<>("P4TRUST", "<unset>"), new Pair<>("P4TICKETS", "<unset>"), new Pair<>("P4FINGERPRINT", "<unset>"), new Pair<>("P4LOGINSSO", "<unset>") )); }
@Test void toProperties_ServerConfig_emptyPassword() { Map<String, String> props = ConfigPropertiesUtil.toProperties( ServerConfig.createFrom( new MockConfigPart() .withUsername("username") .withServerName("servername") .withPassword("") ), "<unset>", "<stored>", "<ns>" ); assertThat(props, mapContainsAll( new Pair<>("P4PORT", portName("servername")), new Pair<>("P4USER", "username"), new Pair<>("P4TRUST", "<unset>"), new Pair<>("P4TICKETS", "<unset>"), new Pair<>("P4FINGERPRINT", "<unset>"), new Pair<>("P4LOGINSSO", "<unset>"), // The user supplied an empty password. This means that a password is stored. new Pair<>("P4PASSWD", "<stored>") )); }
@Test void toProperties_ClientConfig_empty() { MockConfigPart part = new MockConfigPart() .withUsername("username") .withServerName("servername") .withClientname("client"); Map<String, String> props = ConfigPropertiesUtil.toProperties( ClientConfig.createFrom(ServerConfig.createFrom(part), part), "<unset>", "<stored>", "<ns>" ); assertThat(props, mapContainsAll( new Pair<>("P4PORT", portName("servername")), new Pair<>("P4CLIENT", "client"), new Pair<>("P4USER", "username"), new Pair<>("P4PASSWD", "<ns>"), new Pair<>("P4TRUST", "<unset>"), new Pair<>("P4TICKETS", "<unset>"), new Pair<>("P4FINGERPRINT", "<unset>"), new Pair<>("P4CHARSET", "<unset>"), new Pair<>("P4IGNORE", "<unset>"), new Pair<>("P4HOST", "<unset>"), new Pair<>("P4LOGINSSO", "<unset>") )); }
); assertThat(props, mapContainsAll( new Pair<>("P4PORT", portName("servername")), new Pair<>("P4CLIENT", "client"), new Pair<>("P4USER", "username"),
); assertThat(props, mapContainsAll( new Pair<>("P4PORT", portName("servername")), new Pair<>("P4TRUST", "trust.txt"), new Pair<>("P4TICKETS", "auth.txt"),
); assertThat(props, mapContainsAll( new Pair<>("P4PORT", portName("servername")), new Pair<>("P4TRUST", "trust.txt"), new Pair<>("P4USER", "username"),