Permalink
Browse files

Fixing RFC 5848 test.

  • Loading branch information...
1 parent 53a9e18 commit 19c6b6ea6366974a45abdd6289dc20c30de49c0a @squeeks committed Mar 8, 2013
Showing with 33 additions and 12 deletions.
  1. +0 −4 test/fixtures/RFC5848.json
  2. +33 −8 test/parse_5848.js
@@ -1,4 +0,0 @@
-[
- "<110>1 2009-05-03T14:00:39.519307+02:00 host.example.org syslogd 2138 - [ssign-cert VER=\"0111\" RSID=\"1\" SG=\"0\" SPRI=\"0\" TPBL=\"587\" INDEX=\"1\" FLEN=\"587\" FRAG=\"2009-05-03T14:00:39.519005+02:00 K BACsLMZ NCV2NUAwe4RAeAnSQuvv2KS51SnHFAaWJNU2XVDYvW1LjmJgg4vKvQPo3HEOD+2hEkt1zcXADe03u5pmHoWy5FGiyCbglYxJkUJJrQqlTSS6vID9yhsmEnh07w3pOsxmb4qYo0uWQrAAenBweVMlBgV3ZA5IMA8xq8l+i8wCgkWJjCjfLar7s+0X3HVrRroyARv8EAIYoxofh9m N8n821BTTuQnz5hp40d6Z3UudKePu2di5Mx3GFelwnV0Qh5mSs0YkuHJg0mcXyUAoeYry5X6482fUxbm+gOHVmYSDtBmZEB8PTEt8Os8aedWgKEt/E4dT+Hmod4omECLteLXxtScTMgDXyC+bSBMjRRCaeWhHrYYdYBACCWMdTc12hRLJTn8LX99kv1I7qwgieyna8GCJv/rEgC ssS9E1qARM+h19KovIUOhl4VzBw3rK7v8Dlw/CJyYDd5kwSvCwjhO21LiReeS90VPYuZFRC1B82Sub152zOqIcAWsgd4myCCiZbWBsuJ8P0gtarFIpleNacCc6OV3i2Rg==\" SIGN=\"AKAQEUiQptgpd0lKcXbuggGXH/dCdQCgdysrTBLUlbeGAQ4vwrnLOqSL7+c=\"]",
- "<110>1 2009-05-03T14:00:39.529966+02:00 host.example.org syslogd 2138 - [ssign VER=\"0111\" RSID=\"1\" SG=\"0\" SPRI=\"0\" GBC=\"2\" FMN=\"1\" CNT=\"7\" HB=\"K6wzcombEvKJ+UTMcn9bPryAeaU= zrkDcIeaDluypaPCY8WWzwHpPok= zgrWOdpx16ADc7UmckyIFY53icE= XfopJ+S8/hODapiBBCgVQaLqBKg= J67gKMFl/OauTC20ibbydwIlJC8= M5GziVgB6KPY3ERU1HXdSi2vtdw= Wxd/lU7uG/ipEYT9xeqnsfohyH0=\" SIGN=\"AKBbX4J7QkrwuwdbV7Taujk2lvOf8gCgC62We1QYfnrNHz7FzAvdySuMyfM=\"]"
-]
View
@@ -1,15 +1,40 @@
var syslogParser = require('../lib/glossy/parse.js'),
- assert = require('assert'),
- fs = require('fs');
+ assert = require('assert');
assert.ok(syslogParser, 'parser loaded');
-var messages = JSON.parse(fs.readFileSync(__dirname + '/fixtures/RFC5848.json', 'utf8'));
+var fullySigned = '<110>1 2009-05-03T14:00:39.519307+02:00 host.example.org syslogd 2138 - [ssign-cert VER="0111" RSID="1" SG="0" SPRI="0" TPBL="587" INDEX="1" FLEN="587" FRAG="2009-05-03T14:00:39.519005+02:00 K BACsLMZ NCV2NUAwe4RAeAnSQuvv2KS51SnHFAaWJNU2XVDYvW1LjmJgg4vKvQPo3HEOD+2hEkt1zcXADe03u5pmHoWy5FGiyCbglYxJkUJJrQqlTSS6vID9yhsmEnh07w3pOsxmb4qYo0uWQrAAenBweVMlBgV3ZA5IMA8xq8l+i8wCgkWJjCjfLar7s+0X3HVrRroyARv8EAIYoxofh9m N8n821BTTuQnz5hp40d6Z3UudKePu2di5Mx3GFelwnV0Qh5mSs0YkuHJg0mcXyUAoeYry5X6482fUxbm+gOHVmYSDtBmZEB8PTEt8Os8aedWgKEt/E4dT+Hmod4omECLteLXxtScTMgDXyC+bSBMjRRCaeWhHrYYdYBACCWMdTc12hRLJTn8LX99kv1I7qwgieyna8GCJv/rEgC ssS9E1qARM+h19KovIUOhl4VzBw3rK7v8Dlw/CJyYDd5kwSvCwjhO21LiReeS90VPYuZFRC1B82Sub152zOqIcAWsgd4myCCiZbWBsuJ8P0gtarFIpleNacCc6OV3i2Rg==" SIGN="AKAQEUiQptgpd0lKcXbuggGXH/dCdQCgdysrTBLUlbeGAQ4vwrnLOqSL7+c="]';
-for(message in messages) {
- parsed = syslogParser.parse(messages[message]);
- assert.ok(parsed);
-};
+var fullySignedSD = syslogParser.parseStructure(fullySigned);
+assert.deepEqual(fullySignedSD, {
+ 'ssign-cert': {
+ VER: '0111',
+ RSID: '1',
+ SG: '0',
+ SPRI: '0',
+ TPBL: '587',
+ INDEX: '1',
+ FLEN: '587',
+ FRAG: '2009-05-03T14:00:39.519005+02:00 K BACsLMZ NCV2NUAwe4RAeAnSQuvv2KS51SnHFAaWJNU2XVDYvW1LjmJgg4vKvQPo3HEOD+2hEkt1zcXADe03u5pmHoWy5FGiyCbglYxJkUJJrQqlTSS6vID9yhsmEnh07w3pOsxmb4qYo0uWQrAAenBweVMlBgV3ZA5IMA8xq8l+i8wCgkWJjCjfLar7s+0X3HVrRroyARv8EAIYoxofh9m N8n821BTTuQnz5hp40d6Z3UudKePu2di5Mx3GFelwnV0Qh5mSs0YkuHJg0mcXyUAoeYry5X6482fUxbm+gOHVmYSDtBmZEB8PTEt8Os8aedWgKEt/E4dT+Hmod4omECLteLXxtScTMgDXyC+bSBMjRRCaeWhHrYYdYBACCWMdTc12hRLJTn8LX99kv1I7qwgieyna8GCJv/rEgC ssS9E1qARM+h19KovIUOhl4VzBw3rK7v8Dlw/CJyYDd5kwSvCwjhO21LiReeS90VPYuZFRC1B82Sub152zOqIcAWsgd4myCCiZbWBsuJ8P0gtarFIpleNacCc6OV3i2Rg==',
+ SIGN: 'AKAQEUiQptgpd0lKcXbuggGXH/dCdQCgdysrTBLUlbeGAQ4vwrnLOqSL7+c='
+ }
+});
-//TODO expand tests further
+assert.deepEqual(syslogParser.parseSignedCertificate(fullySignedSD['ssign-cert']), {
+ version: '01',
+ hashAlgorithm: 1,
+ hashAlgoString: 'SHA1',
+ sigScheme: 1,
+ rebootSessionID: 1,
+ signatureGroup: 0,
+ signaturePriority: 0,
+ totalPayloadLength: 587,
+ payloadIndex: 1,
+ fragmentLength: 587,
+ payloadTimestamp: new Date('2009-05-03T14:00:39.519005+02:00'),
+ payloadType: 'K',
+ payloadName: 'Public Key',
+ keyBlob: new Buffer(fullySignedSD['ssign-cert']['FRAG'].split(/\s/)[2], encoding='base64'),
+ thisSignature: new Buffer(fullySignedSD['ssign-cert']['SIGN'], encoding='base64')
+});

0 comments on commit 19c6b6e

Please sign in to comment.