Skip to content

Commit

Permalink
#1713 check for login and host
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 25, 2023
1 parent 12f0da8 commit 814bb4d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/rultor/agents/shells/RegistersShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ public Iterable<Directive> process(final XML xml) throws IOException {
hash, this.shell.host(), this.shell.port(),
xml.xpath("/talk/@name").get(0)
);
final String host = this.shell.host();
if (host.isEmpty()) {
throw new Profile.ConfigException(
"SSH host is empty, it's a mistake"
);
}
final String login = this.shell.login();
if (login.isEmpty()) {
throw new Profile.ConfigException(
"SSH login is empty, it's a mistake"
);
}
final String key = this.shell.key();
if (key.isEmpty()) {
throw new Profile.ConfigException(
Expand All @@ -105,9 +117,9 @@ public Iterable<Directive> process(final XML xml) throws IOException {
}
dirs.xpath("/talk").add("shell")
.attr("id", hash)
.add("host").set(this.shell.host()).up()
.add("host").set(host).up()
.add("port").set(Integer.toString(this.shell.port())).up()
.add("login").set(this.shell.login()).up()
.add("login").set(login).up()
.add("key").set(key);
} catch (final Profile.ConfigException ex) {
dirs.xpath("/talk/daemon/script").set(
Expand Down

0 comments on commit 814bb4d

Please sign in to comment.