LocalPeerCommands { protected RequestBuilder getChangeHostnameInAuthorizedKeysCommand( String oldHostname, String newHostname ) { return new RequestBuilder( String.format( "chmod 700 %3$s && sed -i 's/\\b%1$s\\b/%2$s/g' %3$s && chmod 644 %3$s", oldHostname, newHostname, Common.CONTAINER_SSH_FILE ) ); }  RequestBuilder getRegisterManagementContainerCommand( String token ); RequestBuilder getRemoveUserIfExistsCommand( final String username ); RequestBuilder getDestroyContainerCommand( String containerName ); RequestBuilder getRemoveHostnameFromEtcHostsCommand( final HostAddresses hostAddresses );  }
@Test public void testGetChangeHostnameInAuthorizedKeysCommand() throws Exception { assertEquals( "chmod 700 /root/.ssh/authorized_keys && sed -i 's/\\bOLD\\b/NEW/g' /root/.ssh/authorized_keys " + "&& chmod 644 /root/.ssh/authorized_keys", localPeerCommands.getChangeHostnameInAuthorizedKeysCommand( "OLD", "NEW" ).build( "ID" ).getCommand() ); }