Create FLAIM EncDef through dictionary API in test
All checks were successful
Source release / source-package (push) Successful in 1m10s
All checks were successful
Source release / source-package (push) Successful in 1m10s
This commit is contained in:
committed by
Mario Fetka
parent
cac25e847c
commit
6561769229
@@ -17,8 +17,6 @@
|
||||
#define SECRET_ENCDEF 10
|
||||
|
||||
static const char *kDictionary =
|
||||
"0 @10@ EncDef SecretKey\n"
|
||||
" 1 type aes\n"
|
||||
"0 @1@ field Person\n"
|
||||
" 1 type text\n"
|
||||
"0 @2@ field LastName\n"
|
||||
@@ -167,6 +165,29 @@ static void assert_secret_not_plaintext(const char *dir)
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
static void add_encryption_definition(HFDB hDb)
|
||||
{
|
||||
FlmRecord *rec = NULL;
|
||||
void *field = NULL;
|
||||
RCODE rc;
|
||||
|
||||
rec = f_new FlmRecord;
|
||||
if (!rec)
|
||||
{
|
||||
fail("alloc EncDef FlmRecord", FERR_MEM);
|
||||
}
|
||||
|
||||
if (RC_BAD(rc = rec->insertLast(0, FLM_ENCDEF_TAG, FLM_TEXT_TYPE, &field))) fail("insert EncDef root", rc);
|
||||
if (RC_BAD(rc = rec->setNative(field, "SecretKey"))) fail("set EncDef name", rc);
|
||||
if (RC_BAD(rc = rec->insertLast(1, FLM_TYPE_TAG, FLM_TEXT_TYPE, &field))) fail("insert EncDef type", rc);
|
||||
if (RC_BAD(rc = rec->setNative(field, "aes"))) fail("set EncDef type", rc);
|
||||
|
||||
FLMUINT drn = SECRET_ENCDEF;
|
||||
if (RC_BAD(rc = FlmRecordAdd(hDb, FLM_DICT_CONTAINER, &drn, rec, 0))) fail("FlmRecordAdd EncDef", rc);
|
||||
if (drn != SECRET_ENCDEF) fail("EncDef DRN mismatch", 0);
|
||||
rec->Release();
|
||||
}
|
||||
|
||||
static void add_person(HFDB hDb, FLMUINT *drn_out)
|
||||
{
|
||||
FlmRecord *rec = NULL;
|
||||
@@ -269,6 +290,7 @@ int main(int argc, char **argv)
|
||||
if (RC_BAD(rc = FlmStartup())) fail("FlmStartup", rc);
|
||||
if (RC_BAD(rc = FlmDbCreate(db, data, rfl, NULL, kDictionary, NULL, &hDb))) fail("FlmDbCreate", rc);
|
||||
if (RC_BAD(rc = FlmDbTransBegin(hDb, FLM_UPDATE_TRANS, 15))) fail("FlmDbTransBegin", rc);
|
||||
add_encryption_definition(hDb);
|
||||
add_person(hDb, &drn);
|
||||
if (RC_BAD(rc = FlmDbTransCommit(hDb))) fail("FlmDbTransCommit", rc);
|
||||
verify_person(hDb, drn);
|
||||
|
||||
Reference in New Issue
Block a user