node-libpq
node-libpq copied to clipboard
Failing test: no password supplied
I'm getting a failed test:
- async connection works with hard-coded connection parameters: Error: fe_sendauth: no password supplied
I have the default installation of pg 9.4 and libpq-dev via the package manager
@brianc ping
Sorry for missing this the first time - can you connect by typing psql
on your terminal without providing any other connection parameters? The tests all assume you can connect to a PostgreSQL backend via environment variables only. If that's not the case for you you'll need to export environment variables to make the tests pass. If that fixes your issue I'd love to know - I'll document that requirement now in the README
Thanks for your response. I tried running the tests again and I still get the same failing test but with a different error message:
- async connection works: Uncaught Error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Typing psql
, without any other connection parameters, under the postgres
user connects as expected. I'm also running npm test
under the postgres
user as well.
So you're saying you can connect when you type psql
with no parameters but you cannot run the tests with npm test
with no parameters? That's strange - they both use the same library internally (libpq) to connect to postgres. Could you type env | grep PG
on the command line & paste it here?
That's right, no parameters on either command.
XDG_SESSION_ID=2
SHELL=/bin/bash
TERM=screen
USER=postgres
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
MAIL=/var/mail/postgres
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/pgsql/bin
PWD=/home/postgres/test/node_modules/libpq
LANG=en_US.utf8
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
TZ=UTC
SHLVL=1
HOME=/home/postgres
LANGUAGE=en_US:
LOGNAME=postgres
LESSOPEN=| /usr/bin/lesspipe %s
XDG_RUNTIME_DIR=/run/user/1000
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/home/postgres/test/node_modules
Try running by typing PGUSER=postgres npm test
? I think your connecting with ident auth which isn't actually a "thing" - it's just done by the psql client.
Did PGUSER=postgres npm test
, same failing test.
okay...let's try being more explicit with that command...
$ PGUSER=postgres PGHOST=localhost PGPORT=5432 PGDATABASE=postgres npm test
Ok, now I got:
async connection
✓ works
✓ works with hard-coded connection parameters
1) returns an error to the callback if connection fails
1) async connection returns an error to the callback if connection fails:
Error: timeout of 2000ms exceeded
at null.<anonymous> (/home/postgres/test/node_modules/libpq/node_modules/mocha/lib/runnable.js:157:19)
at Timer.listOnTimeout (timers.js:133:15)
boom! looks like it connects! As far as that 2nd one failing....weird that its not returning an error but rather timing out on some dns lookup or something. I'm spinning up an ubuntu box right now so I can test there - I've been developing locally on os x against postgres.app and it has slightly different auth stuff.
Also, I get an child_process: customFds option is deprecated, use stdio instead.
when running the tests.
This is on Ubuntu 14.04, postgres 9.4, node v0.11.14.
Yeah I get that error on node v0.11.14 as well - it's a bug with mocha & not with this module.
I just installed postgres 9.3 and ubuntu 14.04 on a fresh ec2 instance & the tests pass for me.
I think the best thing in this situation might be to debug the test on your end that isn't working & figure out where it's failing & why. A pull request would be very welcome. :smile:
When I use 9.3 from the package manager I get the error noted in the OP, however when I build and use 9.4 beta_2 I get the callback timed out error. I'll dig into this further.
Unfortunately postgres's log shows the third connection being made and then nothing else.
All tests pass if I remove the third async-connection test. Still not sure why the callback isn't fired on connection to a non-existent host.
It may be just timing out before the lookup fails. Try extending the mocha timeout by adding --timeout 15000
to test/mocha.opts.