fixing the password saving test.

This commit is contained in:
Enno Rehling 2016-05-20 22:38:18 +02:00
parent 01035a7325
commit cdd7606f02
3 changed files with 13 additions and 6 deletions

View File

@ -231,21 +231,25 @@ static void test_read_password_external(CuTest *tc) {
CuAssertPtrNotNull(tc, f->_password);
data = gamedata_open(path, "wb");
CuAssertPtrNotNull(tc, data);
WRITE_TOK(data->store, (const char *)f->_password);
WRITE_TOK(data->store, (const char *)f->_password);
WRITE_TOK(data->store, "newpassword");
WRITE_TOK(data->store, "secret");
WRITE_TOK(data->store, "$brokenhash");
gamedata_close(data);
data = gamedata_open(path, "rb");
CuAssertPtrNotNull(tc, data);
data->version = NOCRYPT_VERSION;
_test_read_password(data, f);
CuAssertStrEquals(tc, "newpassword", f->_password);
data->version = BADCRYPT_VERSION;
_test_read_password(data, f);
CuAssertPtrEquals(tc, 0, f->_password);
CuAssertStrEquals(tc, "secret", f->_password);
F = fopen(pwfile, "wt");
fprintf(F, "%s:secret\n", itoa36(f->no));
fprintf(F, "%s:pwfile\n", itoa36(f->no));
fclose(F);
_test_read_password(data, f);
CuAssertPtrNotNull(tc, f->_password);
CuAssertStrEquals(tc, "pwfile", f->_password);
CuAssertTrue(tc, checkpasswd(f, "pwfile"));
gamedata_close(data);
CuAssertTrue(tc, checkpasswd(f, "secret"));
CuAssertIntEquals(tc, 0, remove(path));
CuAssertIntEquals(tc, 0, remove(pwfile));
}

View File

@ -1,3 +1,4 @@
#include <platform.h>
#include <CuTest.h>
#include "log.h"

View File

@ -5,7 +5,9 @@ CD ..
SET ERESSEA=%CD%
CD %SRCDIR%
IF exist build-vs%VSVERSION% goto HAVEDIR
mkdir build-vs%VSVERSION%
:HAVEDIR
cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
PAUSE