Only generate SSH test keys if we run SSH tests

Change-Id: I8433af9ff2e0da89feba18285de7c1e71bb05cd7
This commit is contained in:
Patrick Hiesel
2016-12-22 14:20:47 +01:00
committed by ekempin
parent 244ff8c375
commit 483c2ff40e
2 changed files with 18 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.account.VersionedAuthorizedKeys;
import com.google.gerrit.server.index.account.AccountIndexer;
import com.google.gerrit.server.ssh.SshKeyCache;
import com.google.gerrit.testutil.SshMode;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -112,9 +113,12 @@ public class AccountCreator {
}
}
KeyPair sshKey = genSshKey();
authorizedKeys.addKey(id, publicKey(sshKey, email));
sshKeyCache.evict(username);
KeyPair sshKey = null;
if (SshMode.useSsh()) {
sshKey = genSshKey();
authorizedKeys.addKey(id, publicKey(sshKey, email));
sshKeyCache.evict(username);
}
accountCache.evictByUsername(username);
byEmailCache.evict(email);