fix stuff that can be fixed
This commit is contained in:
parent
82b1769fc9
commit
990a1021b8
@ -27,7 +27,7 @@ spec = do
|
|||||||
res `shouldBe` Left
|
res `shouldBe` Left
|
||||||
(Ldap.ResponseError
|
(Ldap.ResponseError
|
||||||
(Ldap.ResponseErrorCode (Ldap.Type.DeleteRequest
|
(Ldap.ResponseErrorCode (Ldap.Type.DeleteRequest
|
||||||
(Ldap.Type.LdapDn (Ldap.Type.LdapString "cn=oddish, o=localhost")))
|
(Ldap.Type.LdapDn (Ldap.Type.LdapString "cn=oddish,o=localhost")))
|
||||||
Ldap.NoSuchObject
|
Ldap.NoSuchObject
|
||||||
(Dn "o=localhost")
|
(Dn "o=localhost")
|
||||||
"cn=oddish, o=localhost"))
|
"cn=oddish,o=localhost"))
|
||||||
|
|||||||
@ -30,7 +30,7 @@ spec = do
|
|||||||
res `shouldBe` Left
|
res `shouldBe` Left
|
||||||
(ResponseError
|
(ResponseError
|
||||||
(ResponseErrorCode
|
(ResponseErrorCode
|
||||||
(Ldap.Type.ModifyRequest (Ldap.Type.LdapDn (Ldap.Type.LdapString "cn=pikachu, o=localhost"))
|
(Ldap.Type.ModifyRequest (Ldap.Type.LdapDn (Ldap.Type.LdapString "cn=pikachu,o=localhost"))
|
||||||
[( Ldap.Type.Delete
|
[( Ldap.Type.Delete
|
||||||
, Ldap.Type.PartialAttribute
|
, Ldap.Type.PartialAttribute
|
||||||
(Ldap.Type.AttributeDescription (Ldap.Type.LdapString "password"))
|
(Ldap.Type.AttributeDescription (Ldap.Type.LdapString "password"))
|
||||||
|
|||||||
@ -59,49 +59,49 @@ dns (SearchEntry dn _ : es) = dn : dns es
|
|||||||
dns [] = []
|
dns [] = []
|
||||||
|
|
||||||
bulbasaur :: Dn
|
bulbasaur :: Dn
|
||||||
bulbasaur = Dn "cn=bulbasaur, o=localhost"
|
bulbasaur = Dn "cn=bulbasaur,o=localhost"
|
||||||
|
|
||||||
ivysaur :: Dn
|
ivysaur :: Dn
|
||||||
ivysaur = Dn "cn=ivysaur, o=localhost"
|
ivysaur = Dn "cn=ivysaur,o=localhost"
|
||||||
|
|
||||||
venusaur :: Dn
|
venusaur :: Dn
|
||||||
venusaur = Dn "cn=venusaur, o=localhost"
|
venusaur = Dn "cn=venusaur,o=localhost"
|
||||||
|
|
||||||
charmander :: Dn
|
charmander :: Dn
|
||||||
charmander = Dn "cn=charmander, o=localhost"
|
charmander = Dn "cn=charmander,o=localhost"
|
||||||
|
|
||||||
charmeleon :: Dn
|
charmeleon :: Dn
|
||||||
charmeleon = Dn "cn=charmeleon, o=localhost"
|
charmeleon = Dn "cn=charmeleon,o=localhost"
|
||||||
|
|
||||||
charizard :: Dn
|
charizard :: Dn
|
||||||
charizard = Dn "cn=charizard, o=localhost"
|
charizard = Dn "cn=charizard,o=localhost"
|
||||||
|
|
||||||
squirtle :: Dn
|
squirtle :: Dn
|
||||||
squirtle = Dn "cn=squirtle, o=localhost"
|
squirtle = Dn "cn=squirtle,o=localhost"
|
||||||
|
|
||||||
wartortle :: Dn
|
wartortle :: Dn
|
||||||
wartortle = Dn "cn=wartortle, o=localhost"
|
wartortle = Dn "cn=wartortle,o=localhost"
|
||||||
|
|
||||||
blastoise :: Dn
|
blastoise :: Dn
|
||||||
blastoise = Dn "cn=blastoise, o=localhost"
|
blastoise = Dn "cn=blastoise,o=localhost"
|
||||||
|
|
||||||
caterpie :: Dn
|
caterpie :: Dn
|
||||||
caterpie = Dn "cn=caterpie, o=localhost"
|
caterpie = Dn "cn=caterpie,o=localhost"
|
||||||
|
|
||||||
metapod :: Dn
|
metapod :: Dn
|
||||||
metapod = Dn "cn=metapod, o=localhost"
|
metapod = Dn "cn=metapod,o=localhost"
|
||||||
|
|
||||||
butterfree :: Dn
|
butterfree :: Dn
|
||||||
butterfree = Dn "cn=butterfree, o=localhost"
|
butterfree = Dn "cn=butterfree,o=localhost"
|
||||||
|
|
||||||
pikachu :: Dn
|
pikachu :: Dn
|
||||||
pikachu = Dn "cn=pikachu, o=localhost"
|
pikachu = Dn "cn=pikachu,o=localhost"
|
||||||
|
|
||||||
raichu :: Dn
|
raichu :: Dn
|
||||||
raichu = Dn "cn=raichu, o=localhost"
|
raichu = Dn "cn=raichu,o=localhost"
|
||||||
|
|
||||||
vulpix :: Dn
|
vulpix :: Dn
|
||||||
vulpix = Dn "cn=vulpix, o=localhost"
|
vulpix = Dn "cn=vulpix,o=localhost"
|
||||||
|
|
||||||
oddish :: Dn
|
oddish :: Dn
|
||||||
oddish = Dn "cn=oddish, o=localhost"
|
oddish = Dn "cn=oddish,o=localhost"
|
||||||
|
|||||||
39
test/ldap.js
39
test/ldap.js
@ -3,9 +3,18 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var ldapjs = require('ldapjs');
|
var ldapjs = require('ldapjs');
|
||||||
|
|
||||||
|
// Stub unimplemented functionality.
|
||||||
ldapjs.ExtensibleFilter.prototype.matches = ldapjs.EqualityFilter.prototype.matches;
|
ldapjs.ExtensibleFilter.prototype.matches = ldapjs.EqualityFilter.prototype.matches;
|
||||||
ldapjs.ApproximateFilter.prototype.matches = ldapjs.EqualityFilter.prototype.matches;
|
ldapjs.ApproximateFilter.prototype.matches = ldapjs.EqualityFilter.prototype.matches;
|
||||||
|
|
||||||
|
// Remove superfluous spaces from DNs.
|
||||||
|
var wrappee = ldapjs.DN.prototype.format;
|
||||||
|
ldapjs.DN.prototype.format = function(options) {
|
||||||
|
options = options || this._format;
|
||||||
|
options['skipSpace'] = true;
|
||||||
|
return (wrappee.bind(this))(options);
|
||||||
|
};
|
||||||
|
|
||||||
var port = process.env.PORT;
|
var port = process.env.PORT;
|
||||||
var certificate = fs.readFileSync(process.env.SSL_CERT, "utf-8");
|
var certificate = fs.readFileSync(process.env.SSL_CERT, "utf-8");
|
||||||
var key = fs.readFileSync(process.env.SSL_KEY, "utf-8");
|
var key = fs.readFileSync(process.env.SSL_KEY, "utf-8");
|
||||||
@ -13,43 +22,43 @@ var server = ldapjs.createServer({certificate: certificate, key: key});
|
|||||||
|
|
||||||
// <http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_National_Pok%C3%A9dex_number>
|
// <http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_National_Pok%C3%A9dex_number>
|
||||||
var pokemon = [
|
var pokemon = [
|
||||||
{ dn: 'cn=bulbasaur, o=localhost',
|
{ dn: 'cn=bulbasaur,o=localhost',
|
||||||
attributes: { cn: 'bulbasaur', evolution: "0", type: ["grass", "poison"], }
|
attributes: { cn: 'bulbasaur', evolution: "0", type: ["grass", "poison"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=ivysaur, o=localhost',
|
{ dn: 'cn=ivysaur,o=localhost',
|
||||||
attributes: { cn: 'ivysaur', evolution: "1", type: ["grass", "poison"], }
|
attributes: { cn: 'ivysaur', evolution: "1", type: ["grass", "poison"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=venusaur, o=localhost',
|
{ dn: 'cn=venusaur,o=localhost',
|
||||||
attributes: { cn: 'venusaur', evolution: "2", type: ["grass", "poison"], }
|
attributes: { cn: 'venusaur', evolution: "2", type: ["grass", "poison"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=charmander, o=localhost',
|
{ dn: 'cn=charmander,o=localhost',
|
||||||
attributes: { cn: 'charmander', evolution: "0", type: ["fire"], }
|
attributes: { cn: 'charmander', evolution: "0", type: ["fire"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=charmeleon, o=localhost',
|
{ dn: 'cn=charmeleon,o=localhost',
|
||||||
attributes: { cn: 'charmeleon', evolution: "1", type: ["fire"], }
|
attributes: { cn: 'charmeleon', evolution: "1", type: ["fire"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=charizard, o=localhost',
|
{ dn: 'cn=charizard,o=localhost',
|
||||||
attributes: { cn: 'charizard', evolution: "2", type: ["fire", "flying"], }
|
attributes: { cn: 'charizard', evolution: "2", type: ["fire", "flying"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=squirtle, o=localhost',
|
{ dn: 'cn=squirtle,o=localhost',
|
||||||
attributes: { cn: 'squirtle', evolution: "0", type: ["water"], }
|
attributes: { cn: 'squirtle', evolution: "0", type: ["water"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=wartortle, o=localhost',
|
{ dn: 'cn=wartortle,o=localhost',
|
||||||
attributes: { cn: 'wartortle', evolution: "1", type: ["water"], }
|
attributes: { cn: 'wartortle', evolution: "1", type: ["water"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=blastoise, o=localhost',
|
{ dn: 'cn=blastoise,o=localhost',
|
||||||
attributes: { cn: 'blastoise', evolution: "2", type: ["water"], }
|
attributes: { cn: 'blastoise', evolution: "2", type: ["water"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=caterpie, o=localhost',
|
{ dn: 'cn=caterpie,o=localhost',
|
||||||
attributes: { cn: 'caterpie', evolution: "0", type: ["bug"], }
|
attributes: { cn: 'caterpie', evolution: "0", type: ["bug"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=metapod, o=localhost',
|
{ dn: 'cn=metapod,o=localhost',
|
||||||
attributes: { cn: 'metapod', evolution: "1", type: ["bug"], }
|
attributes: { cn: 'metapod', evolution: "1", type: ["bug"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=butterfree, o=localhost',
|
{ dn: 'cn=butterfree,o=localhost',
|
||||||
attributes: { cn: 'butterfree', evolution: "2", type: ["bug", "flying"], }
|
attributes: { cn: 'butterfree', evolution: "2", type: ["bug", "flying"], }
|
||||||
},
|
},
|
||||||
{ dn: 'cn=pikachu, o=localhost',
|
{ dn: 'cn=pikachu,o=localhost',
|
||||||
attributes: { cn: 'pikachu', evolution: "0", type: ["electric"], password: ["i-choose-you"] }
|
attributes: { cn: 'pikachu', evolution: "0", type: ["electric"], password: ["i-choose-you"] }
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -63,8 +72,8 @@ server.bind('cn=admin', function(req, res, next) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.bind('cn=pikachu, o=localhost', function(req, res, next) {
|
server.bind('cn=pikachu,o=localhost', function(req, res, next) {
|
||||||
if ((req.dn.toString() === 'cn=pikachu, o=localhost') && (req.credentials === 'i-choose-you')) {
|
if ((req.dn.toString() === 'cn=pikachu,o=localhost') && (req.credentials === 'i-choose-you')) {
|
||||||
res.end();
|
res.end();
|
||||||
return next();
|
return next();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user