mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
added unittest for yaml export
This commit is contained in:
@@ -313,43 +313,40 @@ void pcpexport_yaml(char *outfile) {
|
|||||||
fprintf(out, "secret-keys:\n");
|
fprintf(out, "secret-keys:\n");
|
||||||
|
|
||||||
for(s=pcpkey_hash; s != NULL; s=(pcp_key_t*)(s->hh.next)) {
|
for(s=pcpkey_hash; s != NULL; s=(pcp_key_t*)(s->hh.next)) {
|
||||||
fprintf(out, "-\n");
|
fprintf(out, " -\n");
|
||||||
fprintf(out, " id: %s\n", s->id);
|
fprintf(out, " id: %s\n", s->id);
|
||||||
fprintf(out, " owner: %s\n", s->owner);
|
fprintf(out, " owner: %s\n", s->owner);
|
||||||
fprintf(out, " mail: %s\n", s->mail);
|
fprintf(out, " mail: %s\n", s->mail);
|
||||||
fprintf(out, " ctime: %ld\n", s->ctime);
|
fprintf(out, " ctime: %ld\n", s->ctime);
|
||||||
fprintf(out, " version: %08x\n", s->version);
|
fprintf(out, " version: %08x\n", s->version);
|
||||||
fprintf(out, " serial: %08x\n", s->serial);
|
fprintf(out, " serial: %08x\n", s->serial);
|
||||||
fprintf(out, " type: %s\n",
|
fprintf(out, " type: %s\n",
|
||||||
(s->type == PCP_KEY_TYPE_MAINSECRET) ? "primary" : " secret");
|
(s->type == PCP_KEY_TYPE_MAINSECRET) ? "primary" : " secret");
|
||||||
fprintf(out, " public: "); pcpprint_bin(out, s->public, 32); fprintf(out, "\n");
|
fprintf(out, " public: "); pcpprint_bin(out, s->public, 32); fprintf(out, "\n");
|
||||||
if(s->secret[0] == 0) {
|
if(s->secret[0] == 0) {
|
||||||
fprintf(out, " encrypted: yes\n");
|
fprintf(out, " encrypted: yes\n");
|
||||||
fprintf(out, " nonce: "); pcpprint_bin(out, s->nonce, 24); fprintf(out, "\n");
|
fprintf(out, " nonce: "); pcpprint_bin(out, s->nonce, 24); fprintf(out, "\n");
|
||||||
fprintf(out, " secret: "); pcpprint_bin(out, s->encrypted, 48); fprintf(out, "\n");
|
fprintf(out, " secret: "); pcpprint_bin(out, s->encrypted, 48); fprintf(out, "\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(out, " encrypted: no\n");
|
fprintf(out, " encrypted: no\n");
|
||||||
fprintf(out, " secret: "); pcpprint_bin(out, s->secret, 32); fprintf(out, "\n");
|
fprintf(out, " secret: "); pcpprint_bin(out, s->secret, 32); fprintf(out, "\n");
|
||||||
}
|
}
|
||||||
fprintf(out, " edpub: "); pcpprint_bin(out, s->edpub, 32); fprintf(out, "\n");
|
fprintf(out, " edpub: "); pcpprint_bin(out, s->edpub, 32); fprintf(out, "\n");
|
||||||
|
|
||||||
fprintf(out, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, "public-keys:\n");
|
fprintf(out, "public-keys:\n");
|
||||||
for(p=pcppubkey_hash; p != NULL; p=(pcp_pubkey_t*)(p->hh.next)) {
|
for(p=pcppubkey_hash; p != NULL; p=(pcp_pubkey_t*)(p->hh.next)) {
|
||||||
fprintf(out, "-\n");
|
fprintf(out, " -\n");
|
||||||
fprintf(out, " id: %s\n", p->id);
|
fprintf(out, " id: %s\n", p->id);
|
||||||
fprintf(out, " owner: %s\n", p->owner);
|
fprintf(out, " owner: %s\n", p->owner);
|
||||||
fprintf(out, " mail: %s\n", p->mail);
|
fprintf(out, " mail: %s\n", p->mail);
|
||||||
fprintf(out, " ctime: %ld\n", p->ctime);
|
fprintf(out, " ctime: %ld\n", p->ctime);
|
||||||
fprintf(out, " version: %08x\n", p->version);
|
fprintf(out, " version: %08x\n", p->version);
|
||||||
fprintf(out, " serial: %08x\n", p->serial);
|
fprintf(out, " serial: %08x\n", p->serial);
|
||||||
fprintf(out, " type: public\n");
|
fprintf(out, " type: public\n");
|
||||||
fprintf(out, " public: "); pcpprint_bin(out, p->public, 32); fprintf(out, "\n");
|
fprintf(out, " public: "); pcpprint_bin(out, p->public, 32); fprintf(out, "\n");
|
||||||
fprintf(out, " edpub: "); pcpprint_bin(out, p->edpub, 32); fprintf(out, "\n");
|
fprintf(out, " edpub: "); pcpprint_bin(out, p->edpub, 32); fprintf(out, "\n");
|
||||||
fprintf(out, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,6 +204,12 @@ dxmorg@florida.cops.gov
|
|||||||
expect = /verified/
|
expect = /verified/
|
||||||
</test>
|
</test>
|
||||||
|
|
||||||
|
#
|
||||||
|
# yaml export test
|
||||||
|
<test check-export-yaml>
|
||||||
|
cmd = $pcp -V va -y | perl -MYAML -MData::Dumper -e "print Dumper(Load(join('',<>)))"
|
||||||
|
expect = /VAR1/
|
||||||
|
</test>
|
||||||
|
|
||||||
#
|
#
|
||||||
# negative tests, check for error handling
|
# negative tests, check for error handling
|
||||||
|
|||||||
Reference in New Issue
Block a user