Skip to content

Commit

Permalink
Release v1.2.0 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson authored Mar 29, 2023
1 parent a6f7833 commit 9178c8b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [ push ]
on: [ pull_request, push ]

env:
CI: true
Expand Down
8 changes: 7 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
### Unreleased

- add redis enabled setting

### [1.2.0] - 2023-03-29

- maint: replace for..i iterator with for..of, add test
- feat: add redis enabled setting, #28


### [1.1.0] - 2022-11-22

Expand Down Expand Up @@ -45,3 +50,4 @@

[1.0.4]: https://github.com/haraka/haraka-plugin-recipient-routes/releases/tag/1.0.4
[1.1.0]: https://github.com/haraka/haraka-plugin-recipient-routes/releases/tag/1.1.0
[1.2.0]: https://github.com/haraka/haraka-plugin-recipient-routes/releases/tag/1.2.0
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ exports.register = function () {
exports.load_rcpt_to_routes_ini = function () {
const plugin = this;
plugin.cfg = plugin.config.get('rcpt_to.routes.ini', {
booleans: [
'+redis.enabled',
],
booleans: [
'+redis.enabled',
],
},
function () {
plugin.load_rcpt_to_routes_ini();
Expand All @@ -45,8 +45,8 @@ exports.load_rcpt_to_routes_ini = function () {
const lowered = {};
if (plugin.cfg.routes) {
const keys = Object.keys(plugin.cfg.routes);
for (let i=0; i < keys.length; i++) {
lowered[keys[i].toLowerCase()] = plugin.cfg.routes[keys[i]];
for (const key of keys) {
lowered[key.toLowerCase()] = plugin.cfg.routes[key];
}
plugin.route_list = lowered;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haraka-plugin-recipient-routes",
"version": "1.1.0",
"version": "1.2.0",
"description": "Haraka plugin that validates and routes mail based on recipient domain or address",
"main": "index.js",
"scripts": {
Expand Down
11 changes: 11 additions & 0 deletions test/config/rcpt_to.routes.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

; [redis]
; host=127.0.0.1
; port=6379
; db=0
; enabled=true

[routes]
matt@example.com=192.168.76.66
bad@example.com=127.0.0.1:26
mixEd@examPle.com=172.16.1.1
15 changes: 11 additions & 4 deletions test/recipient-routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const assert = require('assert')
const path = require('path')

const Address = require('address-rfc2821').Address;
const fixtures = require('haraka-test-fixtures');
Expand All @@ -23,6 +24,7 @@ const hmail = {
function file_setup (done) {
this.server = {};
this.plugin = new fixtures.plugin('index');
this.plugin.config = this.plugin.config.module_config(path.resolve('test'));

this.plugin.register();
this.connection = fixtures.connection.createConnection();
Expand Down Expand Up @@ -61,12 +63,10 @@ describe('haraka-plugin-recipient-routes', function () {
assert.equal(rc, undefined);
assert.equal(msg, undefined);
done()
}, this.connection, [ new Address('<matt@example.com>') ]);
}, this.connection, [ new Address('<miss@example.com>') ]);
})

it('hit returns OK', function (done) {
this.plugin.route_list = { '[email protected]': '192.168.1.1' };

this.plugin.rcpt(function (rc, msg) {
assert.equal(rc, OK);
assert.equal(msg, undefined);
Expand All @@ -75,7 +75,6 @@ describe('haraka-plugin-recipient-routes', function () {
})

it('missing domain', function (done) {
this.plugin.route_list = { '[email protected]': '192.168.1.1' };
try {
this.plugin.rcpt(function (rc, msg) {
assert.ok(false)
Expand All @@ -87,6 +86,14 @@ describe('haraka-plugin-recipient-routes', function () {
done()
}
})

it('lowers mixed case routes', function () {
assert.deepEqual(this.plugin.route_list, {
"[email protected]": "127.0.0.1:26",
"[email protected]": "192.168.76.66",
'[email protected]': '172.16.1.1',
})
})
})

describe('rcpt redis', function () {
Expand Down

0 comments on commit 9178c8b

Please sign in to comment.