Test case: ingesting malformed messages (whitespace keys and kind)

This commit is contained in:
Netscape Navigator 2020-04-07 08:13:28 -05:00
parent 492b2da385
commit d76f72ed88
2 changed files with 10 additions and 6 deletions

View File

@ -53,7 +53,7 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
- [ ] Don't allow any type of whitespace in `kind` or `string` keys. Write a test for this.
- [ ] Add Lipmaa links like the Bamboo folks do.
- [ ] Create regexes in ::Lexer using strings and Regexp.new() for cleaner regexes.
- [ ] Make the switch to LevelDB, RocksDB or similar (currently using Ruby PStore).
- [ ] Make the switch to LevelDB, RocksDB, [UNQLite](https://unqlite.org/features.html) or similar (currently using Ruby PStore).
- [ ] Need a way of importing / exporting a feeds blobs. (see "Bundle Brainstorming" below)
- [ ] Need a way of adding peers messages / gossip to bundles. (see "Bundle Brainstorming" below)
- [ ] Add mandatory `--since=` arg to `bundle create`

View File

@ -143,17 +143,21 @@ RSpec.describe Pigeon::Message do
kind[rand(0...8)] = n
draft = Pigeon::Draft.create(kind: kind)
draft["body"] = "empty"
message = Pigeon::Message.publish(draft)
expect { message.save! }.to raise_error("WIP")
tpl = Pigeon::Message.publish(draft).render
boom = ->() { Pigeon::Lexer.tokenize(tpl) }
expect(boom).to raise_error(Pigeon::Lexer::LexError)
end
end
it "does not allow whitespace in key names" do
WHITESPACE.map do |n|
draft = Pigeon::Draft.create(kind: "unit_test")
draft[n] = "should crash"
message = Pigeon::Message.publish(draft)
expect { message.save! }.to raise_error("WIP")
key = SecureRandom.alphanumeric(8)
key[rand(0...8)] = n
draft[key] = "should crash"
tpl = Pigeon::Message.publish(draft).render
boom = ->() { Pigeon::Lexer.tokenize(tpl) }
expect(boom).to raise_error(Pigeon::Lexer::LexError)
end
end
end