Skip to content

Commit

Permalink
v3.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Feb 17, 2019
1 parent a4c1201 commit 6297f28
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
5 changes: 3 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 3.8.2
## 3.8.2 2019-02-17

* Allow plugin names that are file paths, and allow . in plugin names and tags
* Allow plugin names that are file paths, and allow . in plugin names and tags.
* Plugins with seneca prefixes (seneca- or seneca@/) win - thus joi and seneca-joi in particular, are no longer confused.


## 3.8.1 2019-02-10
Expand Down
5 changes: 2 additions & 3 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ exports.make_plugin_key = function(plugin, origtag) {
}

// Allow file paths, but ...
if(!name.match(/^(\.|\/|\\|\w:)/)) {

if (!name.match(/^(\.|\/|\\|\w:)/)) {
// ... anything else should be well-formed
if (!name.match(/^[a-zA-Z@][a-zA-Z0-9.~_\-/]*$/) || 1024 < name.length) {
throw error('bad_plugin_name', { name: name })
}
}

if ('' != tag && (!tag.match(/^[a-zA-Z0-9.~_-]+$/) || 1024 < tag.length)) {
throw error('bad_plugin_tag', { tag: tag })
}
Expand Down
2 changes: 1 addition & 1 deletion test/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ describe('common', function() {
)

expect(Common.make_plugin_key('foo.1~2-3$_')).equal('foo.1~2-3$_')

try {
Common.make_plugin_key()
expect(false).true()
Expand Down
17 changes: 9 additions & 8 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var it = Shared.make_it(lab)
var Seneca = require('..')

describe('plugin', function() {
// Validates that @seneca/ prefix can be dropped.
it('standard-test-plugin', function(fin) {
Seneca()
.test(fin)
Expand Down Expand Up @@ -813,9 +814,10 @@ describe('plugin', function() {
.use(bar, { a: 3, d: 1 })

.ready(function() {
expect(this.options().plugin).equal(
{ bar: { a: 3, c: 1, d: 1, b: 1 },
foo: { a: 2, c: 3, b: 2, d: 1 } })
expect(this.options().plugin).equal({
bar: { a: 3, c: 1, d: 1, b: 1 },
foo: { a: 2, c: 3, b: 2, d: 1 }
})
fin()
})
})
Expand Down Expand Up @@ -890,23 +892,22 @@ describe('plugin', function() {
})

it('no-name', function(fin) {
var s0 = Seneca({legacy:{transport:false}}).test(fin)
s0.use(function(){})
var s0 = Seneca({ legacy: { transport: false } }).test(fin)
s0.use(function() {})
s0.use('./stubs/plugin/no-name.js')
s0.use(__dirname+'/stubs/plugin/no-name.js')
s0.use(__dirname + '/stubs/plugin/no-name.js')
s0.ready(function() {
expect(Object.keys(s0.list_plugins()).length).equal(3)
fin()
})
})

it('seneca-prefix-wins', function(fin) {
var s0 = Seneca({legacy:{transport:false}}).test(fin)
var s0 = Seneca({ legacy: { transport: false } }).test(fin)
s0.use('joi')
s0.ready(function() {
expect(Object.keys(s0.list_plugins())[0]).equal('joi')
fin()
})
})

})
40 changes: 21 additions & 19 deletions test/transport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,40 +1193,42 @@ describe('transport', function() {
}
})


// Thanks to https://github.com/davide-talesco for this test
// https://github.com/senecajs/seneca-transport/issues/165
it('multi-layer-error', test_opts, function(fin) {
const s1 = Seneca({tag: 's1', legacy:{transport:false}}).quiet()
const s2 = Seneca({tag: 's2', legacy:{transport:false}}).quiet()
const s3 = Seneca({tag: 's3', legacy:{transport:false}}).quiet()
const s1 = Seneca({ tag: 's1', legacy: { transport: false } }).quiet()
const s2 = Seneca({ tag: 's2', legacy: { transport: false } }).quiet()
const s3 = Seneca({ tag: 's3', legacy: { transport: false } }).quiet()

s1.client({port:40402, pin: 'cmd:test2'})
.add('cmd:test1', function(msg, reply){
s1.client({ port: 40402, pin: 'cmd:test2' })
.add('cmd:test1', function(msg, reply) {
this.act('cmd:test2', reply)
})
.listen(40401)

s2.client({port:40403, pin: 'cmd:test3'})
.add('cmd:test2', function(msg, reply){
s2.client({ port: 40403, pin: 'cmd:test3' })
.add('cmd:test2', function(msg, reply) {
this.act('cmd:test3', reply)
})
.listen(40402)

s3.add('cmd:test3', function(msg, reply){
s3.add('cmd:test3', function(msg, reply) {
throw new Error('from-test3')
})
.listen(40403)

s1.ready(s2.ready.bind(s2,s3.ready.bind(s3,function() {
s1.act('cmd:test1', function(err) {
expect(err.message).equal('from-test3')
fin()
})
})))
}).listen(40403)

s1.ready(
s2.ready.bind(
s2,
s3.ready.bind(s3, function() {
s1.act('cmd:test1', function(err) {
expect(err.message).equal('from-test3')
fin()
})
})
)
)
})


it('server can be restarted without issues to clients', test_opts, function(
done
) {
Expand Down

0 comments on commit 6297f28

Please sign in to comment.