Closed VladimirCores closed 6 years ago
Is localhost:3000/api your CouchDB server? If not, then localhost:3000/api/_session will not work...
If you are using a proxy, you may need to proxy all of the various CouchDB URLs in order to get it to work.
As you can see i'm using express-pouchdb here running at localhost:3000/api
Every time i getSession i have an empty name in responce even if i signup and then login
@DQvsRA Can you tell a little more on your environment ?
Where does the db.login()
code executes ? If in the browser, what browser, version, etc...
@nolanlawson @ptitjes have the same issue on safari (11.0.2 (12604.4.7.1.4)) on Chrome it's fine :(
export const userApi = new PouchDB(`http://${process.env.apiUrl}:5984/&`, {
skip_setup: true
})
export const dbSignIn = (params) => {
const { email, password } = params
return userApi.login(email, password)
}
Failed to load resource: the server responded with a status of 404 (Object Not Found)
@lukasborawski The test suite passes fine on Safari 11.0.0. Would you mind cloning pouchdb-authentication
repository, launch a CouchDB server on localhost:5984
and run:
npm install
npm run test-local
and open the url that appears in your terminal with your version of Safari ?
@ptitjes there's no URL :) just this:
@lukasborawski Hmm, sorry about that. It was a bug in the test script, that should be fixed in master. Can you please pull and try again ? (Also, I forgot to mention that your CouchDB must be in Admin Party
mode.)
@ptitjes
Results:
START:
admins
✖ Create and delete admin
✖ "after each" hook for "Create and delete admin"
authentication
✖ Test login/logout
✖ "after each" hook for "Test login/logout"
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
✖ "after each" hook for "Test admin change user password with cookie authentication"
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✖ Test signup
✖ "after each" hook for "Test signup"
users.metadata
✖ Test metadata
✖ "after each" hook for "Test metadata"
Finished in 0.198 secs / 0.104 secs @ 11:34:57 GMT+0100 (CET)
SUMMARY:
✔ 5 tests completed
✖ 10 tests failed
FAILED TESTS:
admins
✖ Create and delete admin
Safari 11.0.2 (Mac OS X 10.12.6)
You are not a server admin.
✖ "after each" hook for "Create and delete admin"
Safari 11.0.2 (Mac OS X 10.12.6)
You are not a server admin.
authentication
✖ Test login/logout
Safari 11.0.2 (Mac OS X 10.12.6)
Document update conflict.
✖ "after each" hook for "Test login/logout"
Safari 11.0.2 (Mac OS X 10.12.6)
You are not a server admin.
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
Safari 11.0.2 (Mac OS X 10.12.6)
You are not a server admin.
✖ "after each" hook for "Test admin change user password with cookie authentication"
Safari 11.0.2 (Mac OS X 10.12.6)
Name or password is incorrect.
users
✖ Test signup
Safari 11.0.2 (Mac OS X 10.12.6)
Document update conflict.
✖ "after each" hook for "Test signup"
Safari 11.0.2 (Mac OS X 10.12.6)
You are not a server admin.
users.metadata
✖ Test metadata
Safari 11.0.2 (Mac OS X 10.12.6)
Document update conflict.
✖ "after each" hook for "Test metadata"
Safari 11.0.2 (Mac OS X 10.12.6)
You are not a server admin.
I'm on admin party and there's a lot of admin fails.
Yep, looks as if you were not in admin party :(
npm run test-phantom
If these fails then it is not a problem of Safari but of configuration of you CouchDB instance.
(BTW the test scripts expect CouchDB to be available at http://localhost:5984
.)
Versions and some configuration information of your CouchDB might help, then
docker
, and then as root:
systemctl start docker
chmod a+rw /var/run/docker.sock
and then, in the pouchdb-authentication directory, run both these tests as user:
SERVER=couchdb:latest CLIENT=phantom npm run test
SERVER=couchdb:latest CLIENT=local npm run test
Please be patient the first time you run the tests, because docker will silently download the couchdb:latest
docker image and it is long !
@ptitjes Results from Phantom:
START:
11 12 2017 12:18:18.825:INFO [framework.browserify]: bundle built
11 12 2017 12:18:18.844:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
11 12 2017 12:18:18.845:INFO [launcher]: Launching browser PhantomJS with concurrency 1
11 12 2017 12:18:18.851:INFO [launcher]: Starting browser PhantomJS
11 12 2017 12:18:20.589:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket Kors32hYbsIRnCTDAAAA with id 26230617
admins
✖ Create and delete admin
✖ Create and delete admin with config url
authentication
✔ Test login/logout
✖ "after each" hook for "Test login/logout"
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
✖ "after each" hook for "Test admin change user password with cookie authentication"
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✔ Test signup
✖ "after each" hook for "Test signup"
users.metadata
✔ Test metadata
✖ "after each" hook for "Test metadata"
Finished in 8.098 secs / 4.294 secs @ 12:18:28 GMT+0100 (CET)
SUMMARY:
✔ 8 tests completed
✖ 7 tests failed
FAILED TESTS:
admins
✖ Create and delete admin
PhantomJS 2.1.1 (Mac OS X 0.0.0)
the object {
"message": [undefined]
"name": "unknown"
"status": 0
} was thrown, throw an Error :)
✖ Create and delete admin with config url
PhantomJS 2.1.1 (Mac OS X 0.0.0)
the object {
"message": [undefined]
"name": "unknown"
"status": 0
} was thrown, throw an Error :)
authentication
✖ "after each" hook for "Test login/logout"
PhantomJS 2.1.1 (Mac OS X 0.0.0)
the object {
"message": [undefined]
"name": "unknown"
"status": 0
} was thrown, throw an Error :)
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
PhantomJS 2.1.1 (Mac OS X 0.0.0)
the object {
"message": [undefined]
"name": "unknown"
"status": 0
} was thrown, throw an Error :)
✖ "after each" hook for "Test admin change user password with cookie authentication"
PhantomJS 2.1.1 (Mac OS X 0.0.0)
Name or password is incorrect.
users
✖ "after each" hook for "Test signup"
PhantomJS 2.1.1 (Mac OS X 0.0.0)
the object {
"message": [undefined]
"name": "unknown"
"status": 0
} was thrown, throw an Error :)
users.metadata
✖ "after each" hook for "Test metadata"
PhantomJS 2.1.1 (Mac OS X 0.0.0)
the object {
"message": [undefined]
"name": "unknown"
"status": 0
} was thrown, throw an Error :)
and as I can see the login/logut tests passing correctly ...
Hi @lukasborawski, no the test suite should pass completely with phantom! So I guess there is a problem with your CouchDB configuration (the status 0
is typical of an inaccessible database and/or CORS problems BTW).
Would you please run the tests from point 2. ?
OK @ptitjes,
the first one:
START:
11 12 2017 14:13:16.658:INFO [framework.browserify]: bundle built
11 12 2017 14:13:16.683:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
11 12 2017 14:13:16.684:INFO [launcher]: Launching browser PhantomJS with concurrency 1
11 12 2017 14:13:16.689:INFO [launcher]: Starting browser PhantomJS
11 12 2017 14:13:18.328:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket F1Aqu_DhNmFtbmf5AAAA with id 60656831
INFO: 'The above 404 is totally normal. PouchDB is just detecting if the remote exists.'
admins
✔ Create and delete admin
✔ Create and delete admin with config url
authentication
✔ Test login/logout
issue-109
✔ Test admin change user password with cookie authentication
✔ Test admin change user password with basic authentication
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✔ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✔ Test that admin can change roles
✔ Test that user cannot change roles
✔ Test wrong user for getUser
✔ Test delete user
✔ Test change password
✔ Test change username
✔ Shouldn't change username if new username already exists
users.metadata
✔ Test metadata
✔ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✔ Test changing metadata using non-reserved word "metadata"
Finished in 3.163 secs / 1.111 secs @ 14:13:21 GMT+0100 (CET)
SUMMARY:
✔ 34 tests completed
and the second:
START:
INFO: 'The above 404 is totally normal. PouchDB is just detecting if the remote exists.'
admins
✔ Create and delete admin
✔ Create and delete admin with config url
authentication
✔ Test login/logout
issue-109
✔ Test admin change user password with cookie authentication
✔ Test admin change user password with basic authentication
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✔ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✔ Test that admin can change roles
✔ Test that user cannot change roles
✔ Test wrong user for getUser
✔ Test delete user
✔ Test change password
✔ Test change username
✔ Shouldn't change username if new username already exists
users.metadata
✔ Test metadata
✔ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✔ Test changing metadata using non-reserved word "metadata"
Finished in 5.256 secs / 2.12 secs @ 14:17:53 GMT+0100 (CET)
SUMMARY:
✔ 34 tests completed
If these tests passing then where is the problem?
My cDB config part for CORS:
[cors]
methods = GET, PUT, POST, HEAD, DELETE
headers = accept, authorization, content-type, origin, referer, x-csrf-token
origins = *
credentials = true
[cluster]
n = 1
@lukasborawski So this is rather a good thing then because it is not a Safari problem (provided you opened the URL for the local test with Safari).
What is the URL of your CouchDB ? If it is different than http://localhost:5984
, then you need to specify it to the test script (sorry it is not yet documented on the README...) like this:
SERVER_HOST="http://myfancyurl:fancyport" CLIENT=local npm run test
@ptitjes not the URL and port are typical ...
Ran: SERVER_HOST="http://localhost:5984" CLIENT=local npm run test
and:
START:
admins
✖ Create and delete admin
✖ "after each" hook for "Create and delete admin"
authentication
✖ Test login/logout
✖ "after each" hook for "Test login/logout"
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
✖ "after each" hook for "Test admin change user password with cookie authentication"
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✔ Test signup
✖ "after each" hook for "Test signup"
users.metadata
✔ Test metadata
✖ "after each" hook for "Test metadata"
Finished in 17.665 secs / 16.357 secs @ 14:58:29 GMT+0100 (CET)
SUMMARY:
✔ 7 tests completed
✖ 8 tests failed
FAILED TESTS:
admins
✖ Create and delete admin
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
✖ "after each" hook for "Create and delete admin"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
authentication
✖ Test login/logout
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
✖ "after each" hook for "Test login/logout"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
✖ "after each" hook for "Test admin change user password with cookie authentication"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
users
✖ "after each" hook for "Test signup"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
users.metadata
✖ "after each" hook for "Test metadata"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
@lukasborawski Can you please do:
curl http://localhost:5984
@ptitjes
{"couchdb":"Welcome","version":"2.1.0","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
@lukasborawski I don't know what you're doing wrong. But the Error: Timeout of 2000ms exceeded.
in the last tests you run indicates that you database is not accessible...
@ptitjes My mistake, I was using the remote db. But ran it on local one, I'm logged as an admin and sitll dosn't have access to the admin tests ...
But, the results:
START:
admins
✖ Create and delete admin
✖ "after each" hook for "Create and delete admin"
authentication
✖ Test login/logout
✖ "after each" hook for "Test login/logout"
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
✖ "after each" hook for "Test admin change user password with cookie authentication"
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✖ Test signup
✖ "after each" hook for "Test signup"
users.metadata
✖ Test metadata
✖ "after each" hook for "Test metadata"
Finished in 0.362 secs / 0.182 secs @ 16:14:28 GMT+0100 (CET)
SUMMARY:
✔ 5 tests completed
✖ 10 tests failed
FAILED TESTS:
admins
✖ Create and delete admin
Chrome 62.0.3202 (Mac OS X 10.12.6)
You are not a server admin.
✖ "after each" hook for "Create and delete admin"
Chrome 62.0.3202 (Mac OS X 10.12.6)
You are not a server admin.
authentication
✖ Test login/logout
Chrome 62.0.3202 (Mac OS X 10.12.6)
Document update conflict.
✖ "after each" hook for "Test login/logout"
Chrome 62.0.3202 (Mac OS X 10.12.6)
You are not a server admin.
issue-109
✖ "before each" hook for "Test admin change user password with cookie authentication"
Chrome 62.0.3202 (Mac OS X 10.12.6)
You are not a server admin.
✖ "after each" hook for "Test admin change user password with cookie authentication"
Chrome 62.0.3202 (Mac OS X 10.12.6)
Name or password is incorrect.
users
✖ Test signup
Chrome 62.0.3202 (Mac OS X 10.12.6)
Document update conflict.
✖ "after each" hook for "Test signup"
Chrome 62.0.3202 (Mac OS X 10.12.6)
You are not a server admin.
users.metadata
✖ Test metadata
Chrome 62.0.3202 (Mac OS X 10.12.6)
Document update conflict.
✖ "after each" hook for "Test metadata"
Chrome 62.0.3202 (Mac OS X 10.12.6)
You are not a server admin.
@lukasborawski What do you mean by
I'm logged as an admin
The CouchDB instance must be in Admin Party to run the test suite.
(Off topic, you should update all your 2.1.0 CouchDB instance to 2.1.1 for security reasons.)
@ptitjes OK, succeed:
START:
admins
✔ Create and delete admin
✔ Create and delete admin with config url
authentication
✖ Test login/logout
issue-109
✔ Test admin change user password with cookie authentication
✔ Test admin change user password with basic authentication
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✖ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✔ Test that admin can change roles
✔ Test that user cannot change roles
✔ Test wrong user for getUser
✔ Test delete user
✔ Test change password
✔ Test change username
✔ Shouldn't change username if new username already exists
users.metadata
✔ Test metadata
✔ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✔ Test changing metadata using non-reserved word "metadata"
Finished in 5.478 secs / 2.303 secs @ 16:35:15 GMT+0100 (CET)
SUMMARY:
✔ 32 tests completed
✖ 2 tests failed
FAILED TESTS:
authentication
✖ Test login/logout
Chrome 62.0.3202 (Mac OS X 10.12.6)
Document update conflict.
users
✖ Test signup
Chrome 62.0.3202 (Mac OS X 10.12.6)
Document update conflict.
So there is some problems with logging/signing in ...
@lukasborawski You said it was a Safari problem but that Chrome was fine. What you show is run on Chrome. And you always come back with different errors. Remember that I am not paid to help you.
As I've shown you the test suite does run on all those configurations when the server is properly configured. So I would be glad if you investigate and try to scientifically identify what is your problem.
@ptitjes I've just did what you want from the very beginning, and right now as you can see all tests passed without the login one which is the original issue. But to be clear, there are tests for Safari:
START:
admins
✔ Create and delete admin
✔ Create and delete admin with config url
authentication
✖ Test login/logout
issue-109
✔ Test admin change user password with cookie authentication
✔ Test admin change user password with basic authentication
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
users
✖ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✔ Test that admin can change roles
✔ Test that user cannot change roles
✔ Test wrong user for getUser
✔ Test delete user
✔ Test change password
✔ Test change username
✔ Shouldn't change username if new username already exists
users.metadata
✔ Test metadata
✔ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✔ Test changing metadata using non-reserved word "metadata"
Finished in 4.221 secs / 1.911 secs @ 17:03:10 GMT+0100 (CET)
SUMMARY:
✔ 32 tests completed
✖ 2 tests failed
FAILED TESTS:
authentication
✖ Test login/logout
Safari 11.0.2 (Mac OS X 10.12.6)
Document update conflict.
users
✖ Test signup
Safari 11.0.2 (Mac OS X 10.12.6)
Document update conflict.
The same thing.
I don't know where to find the bug, it's not a my solution, that's why I'm asking here :) Sorry if it's too much. Also couple of other users had the same problems, so we can help the others too.
@ptitjes and dude, this is open source, once you help me next time I or someone else will help you. That's how the world works. Nobody isn't paid here, and this is the magic.
@lukasborawski You have all the tools at hand to understand where your problems come from. Use deduction to understand why the test suites work when they use docker and what is wrong with your CouchDB instance that makes the test suite fail. I can't make all the work for you and also don't have access to your environment. When you have a better view of the problem, I'll be happy to help solve it if it is a problem of the library.
@lukasborawski
have the same issue on safari (11.0.2 (12604.4.7.1.4)) on Chrome it's fine :(
I had similar problems. My problems are caused by safaris very restrictive cookie policy. The problem occures when couchdb (db.domain.com) and website (www.domain.com) are reference by different domains. I am now using basic auth over https which works fine... safari goes the same way as internet explorer did...
Closing this issue as it seems to be stale. Please do reopen a ticket if you still experience this.
Hi
I facing one problem and i'm complete stuck. I trying to login but have an error
Im running local pouch-express
I start thinking to switch back to meteor ...