skip excessive password generation in tests.

This commit is contained in:
Enno Rehling 2018-09-26 20:19:59 +02:00
parent ae05d6d9e9
commit f513c2c68a
4 changed files with 11 additions and 6 deletions

View file

@ -934,7 +934,8 @@ static void seed_player(state *st, const newfaction *player) {
if (r) {
const char *at = strchr(player->email, '@');
faction *f;
addplayer(r, f = addfaction(player->email, player->password,
const char *password = player->password ? player->password : itoa36(rng_int());
addplayer(r, f = addfaction(player->email, password,
player->race, player->lang,
player->subscription));
if (at) {

View file

@ -245,6 +245,7 @@ faction *addfaction(const char *email, const char *password,
f->alliance_joindate = turn;
f->lastorders = turn;
f->_alive = true;
f->_password = NULL;
f->age = 0;
f->race = frace;
f->magiegebiet = 0;
@ -252,9 +253,10 @@ faction *addfaction(const char *email, const char *password,
f->subscription = subscription;
f->flags = FFL_ISNEW|FFL_PWMSG;
if (!password) password = itoa36(rng_int());
faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT));
ADDMSG(&f->msgs, msg_message("changepasswd", "value", password));
if (password) {
faction_setpassword(f, password_encode(password, PASSWORD_DEFAULT));
ADDMSG(&f->msgs, msg_message("changepasswd", "value", password));
}
f->options =
WANT_OPTION(O_REPORT) | WANT_OPTION(O_ZUGVORLAGE) |

View file

@ -112,7 +112,7 @@ static void test_addfaction(CuTest *tc) {
test_setup();
rc = rc_get_or_create("human");
lang = test_create_locale();
f = addfaction("test@eressea.de", "hurrdurr", rc, lang, 1234);
f = addfaction("test@eressea.de", NULL, rc, lang, 1234);
CuAssertPtrNotNull(tc, f);
CuAssertPtrNotNull(tc, f->name);
CuAssertPtrEquals(tc, NULL, (void *)f->units);

View file

@ -550,13 +550,15 @@ int autoseed(newfaction ** players, int nsize, int max_agediff)
newfaction **nfp, *nextf = *players;
faction *f;
unit *u;
const char * password;
isize += REGIONS_PER_FACTION;
terraform_region(r, preferred_terrain(nextf->race));
prepare_starting_region(r);
++tsize;
assert(r->land && r->units == 0);
u = addplayer(r, addfaction(nextf->email, nextf->password, nextf->race,
password = nextf->password ? nextf->password : itoa36(rng_int());
u = addplayer(r, addfaction(nextf->email, password, nextf->race,
nextf->lang, nextf->subscription));
f = u->faction;
fset(f, FFL_ISNEW);