Make an LDAP fake server for tests
Categories
(MailNews Core :: Testing Infrastructure, task)
Tracking
(thunderbird_esr78 wontfix)
Tracking | Status | |
---|---|---|
thunderbird_esr78 | --- | wontfix |
People
(Reporter: jcranmer, Assigned: benc)
Details
Attachments
(1 file, 2 obsolete files)
29.19 KB,
patch
|
benc
:
review+
|
Details | Diff | Splinter Review |
Comment 1•14 years ago
|
||
Reporter | ||
Comment 2•14 years ago
|
||
Comment 3•10 years ago
|
||
Updated•6 years ago
|
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
Assignee | ||
Comment 5•5 years ago
|
||
There is already mailnews/addrbook/test/LDAPServer.jsm
, although that seems to require manual pumping, and I couldn't figure a way to get it working with nsILDAPSyncQuery
. So I wrote another one, drawing on LDAPServer.jsm and the various other fake servers scattered about the codebase.
It's pretty basic - supports loading in test data and performing some simple searches. But it's easy to extend, so we should be able to add whatever other LDAP functionality we need as we add more LDAP tests.
It also includes a generic binary server, which might be handy for hacking up fake servers to test other protocols.
Comment 6•5 years ago
|
||
Updated•5 years ago
|
Assignee | ||
Comment 7•5 years ago
•
|
||
Revision mainly to tidy up jsdoc use.
Kind of at the outer limits of my JS knowledge here - in particular my implementation of Connection.read()
seems a little off: mixing Promises with async. Suggestions for improvement welcome!
(In reply to Magnus Melin [:mkmelin] from comment #6)
> ::: mailnews/test/fakeserver/Binaryd.jsm
> @@ +105,5 @@
> > + // if we get here, assume the error occured because we're
> > + // shutting down, and ignore it.
> > + } else {
> > + // if we get here, something went wrong.
> > + dump("ERROR " + e.toString());
>
> Should the error be let un-caught instead?
>
> @@ +109,5 @@
> > + dump("ERROR " + e.toString());
> > + }
> > + }
> > + conn.close();
> > + delete server._connections[connID];
>
> and these in a finally clause?
I'm not sure yet. For a real server, you want it to keep running even if one connection explodes, so I kind of think our fake server should aim for that. But for testing purposes it could be nice if the whole server explodes too :-)
I've left it as is for now. It can be revisited if some tests require a change.
Comment 8•5 years ago
|
||
Assignee | ||
Comment 9•5 years ago
|
||
(In reply to Geoff Lankow (:darktrojan) from comment #8)
All good stuff and mostly implemented. Exceptions as noted below.
An alternative approach would be to make these methods members of
BinaryServer and callsocket.asyncListen(this)
, which would remove the
need for theserver
variable. It'd help with your TODO in stop() as well.
I think some of the other fake servers do this, but I wanted to keep the BinaryServer public interface as trivial as possible. I've found lots of cases in C-C where things derive from listeners to handle internal stuff (mainly because C++ is a bit annoying), and so so many times it's really confused me. So I decided to hide the listener, even if it makes the implementation a little more finicky.
- @param {number} type - BER type byte
Let's have the types as constants somewhere so that we don't have to
remember the values.
I'm not yet sure on the best way to tackle it as there are a few cases where you're really treating them as bitfields (class/sequence/tag). You can make up helper functions, but they tend to end up producing more verbose code which obscures things more than just fiddling bits directly would...
I'll have a go next time I'm digging about in this - At the very least, I'll make sure the basic types have some constants. What's the best way to handle these in JS? Is a module somewhere in C-C you think is a particularly good example of defining constants?
for...in is a bit old hat these days. There are potential pitfalls it's easy
to forget about. It's probably fine here but I'd usefor (let [attr, val] of Object.entries(e.attributes))
.
Cool - that's exactly the kind of JS stuff I need to learn!
An easier way to check if a JS variable is an array is
Array.isArray
.
Doh! I discovered that I'd already visited the MDN page for Array.isArray
at some point in the past too!
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 10•5 years ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/d5affc0fea36
Add a fake LDAP server. r=darktrojan
Description
•