forked from github/server
work factor 12 is incredibly slow, don't use it in tests.
This commit is contained in:
parent
2e9bde0261
commit
ae05d6d9e9
6 changed files with 10 additions and 7 deletions
|
@ -487,6 +487,7 @@ static void test_recruit_insect(CuTest *tc) {
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
test_create_calendar();
|
test_create_calendar();
|
||||||
|
test_create_terrain("desert", -1);
|
||||||
f = test_create_faction(test_create_race("insect"));
|
f = test_create_faction(test_create_race("insect"));
|
||||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||||
u->thisorder = create_order(K_RECRUIT, f->locale, "%d", 1);
|
u->thisorder = create_order(K_RECRUIT, f->locale, "%d", 1);
|
||||||
|
|
|
@ -441,16 +441,15 @@ static void test_read_password_external(CuTest *tc) {
|
||||||
data.strm.api->rewind(data.strm.handle);
|
data.strm.api->rewind(data.strm.handle);
|
||||||
data.version = NOCRYPT_VERSION;
|
data.version = NOCRYPT_VERSION;
|
||||||
_test_read_password(&data, f);
|
_test_read_password(&data, f);
|
||||||
CuAssertStrEquals(tc, "newpassword", f->_password);
|
CuAssertTrue(tc, checkpasswd(f, "newpassword"));
|
||||||
data.version = BADCRYPT_VERSION;
|
data.version = BADCRYPT_VERSION;
|
||||||
_test_read_password(&data, f);
|
_test_read_password(&data, f);
|
||||||
CuAssertStrEquals(tc, "secret", f->_password);
|
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
||||||
F = fopen(pwfile, "wt");
|
F = fopen(pwfile, "wt");
|
||||||
fprintf(F, "%s:pwfile\n", itoa36(f->no));
|
fprintf(F, "%s:pwfile\n", itoa36(f->no));
|
||||||
fclose(F);
|
fclose(F);
|
||||||
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
CuAssertTrue(tc, checkpasswd(f, "secret"));
|
||||||
_test_read_password(&data, f);
|
_test_read_password(&data, f);
|
||||||
CuAssertStrEquals(tc, "pwfile", f->_password);
|
|
||||||
CuAssertTrue(tc, checkpasswd(f, "pwfile"));
|
CuAssertTrue(tc, checkpasswd(f, "pwfile"));
|
||||||
mstream_done(&data.strm);
|
mstream_done(&data.strm);
|
||||||
gamedata_done(&data);
|
gamedata_done(&data);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
|
#include <util/password.h>
|
||||||
#include <util/strings.h>
|
#include <util/strings.h>
|
||||||
#include <util/variant.h>
|
#include <util/variant.h>
|
||||||
|
|
||||||
|
@ -159,6 +160,7 @@ int RunAllTests(int argc, char *argv[])
|
||||||
CuSuite *summary = CuSuiteNew();
|
CuSuite *summary = CuSuiteNew();
|
||||||
int fail_count;
|
int fail_count;
|
||||||
game_init();
|
game_init();
|
||||||
|
bcrypt_workfactor = 4;
|
||||||
while (suites) {
|
while (suites) {
|
||||||
suite *s = suites->next;
|
suite *s = suites->next;
|
||||||
RunTests(suites->csuite, suites->name);
|
RunTests(suites->csuite, suites->name);
|
||||||
|
|
|
@ -36,10 +36,9 @@
|
||||||
#define FAMILIAR_FIX_VERSION 359 /* familiar links are fixed */
|
#define FAMILIAR_FIX_VERSION 359 /* familiar links are fixed */
|
||||||
#define SKILLSORT_VERSION 360 /* u->skills is sorted */
|
#define SKILLSORT_VERSION 360 /* u->skills is sorted */
|
||||||
#define LANDDISPLAY_VERSION 360 /* r.display is now in r.land.display */
|
#define LANDDISPLAY_VERSION 360 /* r.display is now in r.land.display */
|
||||||
/* unfinished: */
|
#define CRYPT_VERSION 361 /* passwords are encrypted */
|
||||||
#define CRYPT_VERSION 400 /* passwords are encrypted */
|
|
||||||
|
|
||||||
#define RELEASE_VERSION LANDDISPLAY_VERSION /* current datafile */
|
#define RELEASE_VERSION CRYPT_VERSION /* current datafile */
|
||||||
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
||||||
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ typedef enum cryptalgo_t {
|
||||||
PASSWORD_PLAINTEXT,
|
PASSWORD_PLAINTEXT,
|
||||||
PASSWORD_BCRYPT
|
PASSWORD_BCRYPT
|
||||||
} cryptalgo_t;
|
} cryptalgo_t;
|
||||||
#define PASSWORD_DEFAULT PASSWORD_PLAINTEXT
|
#define PASSWORD_DEFAULT PASSWORD_BCRYPT
|
||||||
|
|
||||||
extern int bcrypt_workfactor;
|
extern int bcrypt_workfactor;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ static void test_passwords(CuTest *tc) {
|
||||||
const char *hash;
|
const char *hash;
|
||||||
|
|
||||||
if (password_is_implemented(PASSWORD_BCRYPT)) {
|
if (password_is_implemented(PASSWORD_BCRYPT)) {
|
||||||
|
int wf = bcrypt_workfactor;
|
||||||
bcrypt_workfactor = 4;
|
bcrypt_workfactor = 4;
|
||||||
hash = password_encode("password", PASSWORD_BCRYPT);
|
hash = password_encode("password", PASSWORD_BCRYPT);
|
||||||
CuAssertPtrNotNull(tc, hash);
|
CuAssertPtrNotNull(tc, hash);
|
||||||
|
@ -18,6 +19,7 @@ static void test_passwords(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, '$', hash[6]);
|
CuAssertIntEquals(tc, '$', hash[6]);
|
||||||
CuAssertIntEquals(tc, VERIFY_OK, password_verify(hash, "password"));
|
CuAssertIntEquals(tc, VERIFY_OK, password_verify(hash, "password"));
|
||||||
CuAssertIntEquals(tc, VERIFY_FAIL, password_verify(hash, "arseword"));
|
CuAssertIntEquals(tc, VERIFY_FAIL, password_verify(hash, "arseword"));
|
||||||
|
bcrypt_workfactor = wf;
|
||||||
}
|
}
|
||||||
if (password_is_implemented(PASSWORD_PLAINTEXT)) {
|
if (password_is_implemented(PASSWORD_PLAINTEXT)) {
|
||||||
hash = password_encode("password", PASSWORD_PLAINTEXT);
|
hash = password_encode("password", PASSWORD_PLAINTEXT);
|
||||||
|
|
Loading…
Reference in a new issue