Giter Club home page Giter Club logo

backend-test's People

Contributors

ai avatar dependabot[bot] avatar egregors avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

backend-test's Issues

Issue with Processes subscriptions meta id

test: ✖ 11 Processes subscriptions

All seems good, but I return wrong meta id: 6 instead of 5:

✖ 11 Processes subscriptions

  Server sent {"type":"logux/processed","id":"6 10:2:1 0"}, instead of {"type":"logux/processed","id":"5 10:2:1 0"} action

Test:      /Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/backend-test/tests/actions.js:41:3
Re-run it: npx @logux/backend-test http://localhost:8000/logux/ 11

on this step in the answer you are expecting "id":"5 10:2:1 0", but logux server sent action:

{
  "command": "action",
  "action": {
    "type": "logux/subscribe",
    "channel": "users/10"
  },
  "meta": {
    "id": "6 10:2:1 0",
    "time": 6,
    "subprotocol": "1.0.0",
    "reasons": [],
    "server": "server:1"
  },
  "headers": {}
}

with 'id': '6 10:2:1 0'. What could be wrong here?

Full log:

2020-07-16 10:44:52,762 - logux.views - DEBUG - got auth cmd: {'command': 'auth', 'authId': 'i92rJ6WhRaArUbr7oQpyU', 'userId': '10', 'token': '10:good', 'headers': {}, 'cookie': {}, 'subprotocol': '1.0.0'}
2020-07-16 10:44:52,763 - logux.views - DEBUG - {'answer': 'authenticated', 'subprotocol': '1.0.0', 'authId': 'i92rJ6WhRaArUbr7oQpyU'}
[16/Jul/2020 10:44:52] "POST /logux/ HTTP/1.1" 200 88
2020-07-16 10:44:52,773 - logux.views - DEBUG - got auth cmd: {'command': 'auth', 'authId': 'DOpuTRot3UQabWQsZhbqb', 'userId': '10', 'token': '10:good', 'headers': {}, 'cookie': {}, 'subprotocol': '1.0.0'}
2020-07-16 10:44:52,773 - logux.views - DEBUG - {'answer': 'authenticated', 'subprotocol': '1.0.0', 'authId': 'DOpuTRot3UQabWQsZhbqb'}
[16/Jul/2020 10:44:52] "POST /logux/ HTTP/1.1" 200 88
2020-07-16 10:44:52,780 - logux.views - DEBUG - got auth cmd: {'command': 'auth', 'authId': 'uWIt1eMgqp9nn23k1_Mue', 'userId': '10', 'token': '10:good', 'headers': {}, 'cookie': {}, 'subprotocol': '1.0.0'}
2020-07-16 10:44:52,780 - logux.views - DEBUG - {'answer': 'authenticated', 'subprotocol': '1.0.0', 'authId': 'uWIt1eMgqp9nn23k1_Mue'}
[16/Jul/2020 10:44:52] "POST /logux/ HTTP/1.1" 200 88
2020-07-16 10:44:52,788 - logux.views - DEBUG - got action: {'command': 'action', 'action': {'type': 'logux/subscribe', 'channel': 'users/10'}, 'meta': {'id': '1 10:1:1 0', 'time': 1, 'subprotocol': '1.0.0', 'reasons': [], 'server': 'server:1'}, 'headers': {}}
2020-07-16 10:44:52,788 - logux.views - DEBUG - got subscription for channel: users/10
2020-07-16 10:44:52,790 - logux.views - DEBUG - {'answer': 'approved', 'id': '1 10:1:1 0'}
2020-07-16 10:44:52,790 - logux.views - DEBUG - {'answer': 'action', 'id': '1 10:1:1 0', 'action': {'type': 'users/name', 'payload': {'userId': '10', 'name': 'Name'}}, 'meta': {'clients': ['10:1']}}
2020-07-16 10:44:52,790 - logux.views - DEBUG - {'answer': 'processed', 'id': '1 10:1:1 0'}
[16/Jul/2020 10:44:52] "POST /logux/ HTTP/1.1" 200 241
2020-07-16 10:44:52,798 - logux.views - DEBUG - got action: {'command': 'action', 'action': {'type': 'users/name', 'payload': {'userId': '10', 'name': 'Name'}}, 'meta': {'id': '4 10:1:1 0', 'time': 4, 'subprotocol': '1.0.0'}, 'headers': {}}
2020-07-16 10:44:52,801 - logux.views - DEBUG - {'answer': 'resend', 'id': '4 10:1:1 0', 'channels': ['users/10']}
2020-07-16 10:44:52,802 - logux.views - DEBUG - {'answer': 'approved', 'id': '4 10:1:1 0'}
2020-07-16 10:44:52,802 - logux.views - DEBUG - {'answer': 'processed', 'id': '4 10:1:1 0'}
[16/Jul/2020 10:44:52] "POST /logux/ HTTP/1.1" 200 157
2020-07-16 10:44:52,808 - logux.views - DEBUG - got action: {'command': 'action', 'action': {'type': 'logux/subscribe', 'channel': 'users/10'}, 'meta': {'id': '6 10:2:1 0', 'time': 6, 'subprotocol': '1.0.0', 'reasons': [], 'server': 'server:1'}, 'headers': {}}
2020-07-16 10:44:52,808 - logux.views - DEBUG - got subscription for channel: users/10
2020-07-16 10:44:52,810 - logux.views - DEBUG - {'answer': 'approved', 'id': '6 10:2:1 0'}
2020-07-16 10:44:52,810 - logux.views - DEBUG - {'answer': 'action', 'id': '6 10:2:1 0', 'action': {'type': 'users/name', 'payload': {'userId': '10', 'name': 'Name'}}, 'meta': {'clients': ['10:2']}}
2020-07-16 10:44:52,810 - logux.views - DEBUG - {'answer': 'processed', 'id': '6 10:2:1 0'}
[16/Jul/2020 10:44:52] "POST /logux/ HTTP/1.1" 200 241

Incomprehensible condition for test: 12 Sends action from the back-end

On users/clean action sends users/name action to the Logux Server for all users with the name.

Do you meat I should send_back users/name action for every User from DB with not empty names?

If so, idk what I doing wrong. let's look on the Log. (Test runs standalone):

2020-07-20 04:19:55,947 - logux.views - DEBUG - got auth cmd: {'command': 'auth', 'authId': 'BBqszUbNPDCYFDBZb-RhL', 'userId': '10', 'token': '10:good', 'headers': {}, 'cookie': {}, 'subprotocol': '1.0.0'}
2020-07-20 04:19:55,947 - logux.views - DEBUG - {'answer': 'authenticated', 'subprotocol': '1.0.0', 'authId': 'BBqszUbNPDCYFDBZb-RhL'}
[20/Jul/2020 04:19:55] "POST /logux/ HTTP/1.1" 200 88
2020-07-20 04:19:55,959 - logux.views - DEBUG - got action: {'command': 'action', 'action': {'type': 'users/name', 'payload': {'userId': '10', 'name': 'Name'}}, 'meta': {'id': '1 10:1:1 0', 'time': 1, 'subprotocol': '1.0.0'}, 'headers': {}}
2020-07-20 04:19:55,965 - logux.views - DEBUG - {'answer': 'resend', 'id': '1 10:1:1 0', 'channels': ['users/10']}
2020-07-20 04:19:55,965 - logux.views - DEBUG - {'answer': 'approved', 'id': '1 10:1:1 0'}
2020-07-20 04:19:55,965 - logux.views - DEBUG - {'answer': 'processed', 'id': '1 10:1:1 0'}
[20/Jul/2020 04:19:55] "POST /logux/ HTTP/1.1" 200 157
2020-07-20 04:19:55,975 - logux.views - DEBUG - got action: {'command': 'action', 'action': {'type': 'logux/subscribe', 'channel': 'users/10'}, 'meta': {'id': '3 10:1:1 0', 'time': 3, 'subprotocol': '1.0.0', 'reasons': [], 'server': 'server:1'}, 'headers': {}}
2020-07-20 04:19:55,975 - logux.views - DEBUG - got subscription for channel: users/10
2020-07-20 04:19:55,980 - logux.views - DEBUG - {'answer': 'approved', 'id': '3 10:1:1 0'}
2020-07-20 04:19:55,980 - logux.views - DEBUG - {'answer': 'action', 'id': '3 10:1:1 0', 'action': {'type': 'users/name', 'payload': {'userId': '10', 'name': 'Name'}}, 'meta': {'clients': ['10:1']}}
2020-07-20 04:19:55,980 - logux.views - DEBUG - {'answer': 'processed', 'id': '3 10:1:1 0'}
[20/Jul/2020 04:19:55] "POST /logux/ HTTP/1.1" 200 241
2020-07-20 04:19:55,989 - logux.views - DEBUG - got action: {'command': 'action', 'action': {'type': 'users/clean'}, 'meta': {'id': '6 10:1:1 0', 'time': 6, 'subprotocol': '1.0.0'}, 'headers': {}}
2020-07-20 04:19:55,992 - logux.core - DEBUG - logux_add action {'type': 'users/name', 'payload': {'userId': '10', 'name': 'Name'}} with meta {'clients': ['10:1']} to Logux
2020-07-20 04:19:56,005 - urllib3.connectionpool - DEBUG - Starting new HTTP connection (1): localhost:31337
2020-07-20 04:19:56,010 - urllib3.connectionpool - DEBUG - http://localhost:31337 "POST / HTTP/1.1" 200 0
2020-07-20 04:19:56,011 - logux.core - DEBUG - Logux answer is 200: 
2020-07-20 04:19:56,011 - logux.views - DEBUG - {'answer': 'resend', 'id': '6 10:1:1 0', 'channels': []}
2020-07-20 04:19:56,011 - logux.views - DEBUG - {'answer': 'approved', 'id': '6 10:1:1 0'}
2020-07-20 04:19:56,011 - logux.views - DEBUG - {'answer': 'processed', 'id': '6 10:1:1 0'}
[20/Jul/2020 04:19:56] "POST /logux/ HTTP/1.1" 200 147

The backend-test commands:

  • auth
  • users/name (and set username to "Name")
  • logux/subscribe
  • users/clean (which should send_back users/name with non null names)

But I got an error:

Server sent 
{"type":"users/name","payload":{"userId":"10","name":"Name"}}, instead of 
{"type":"users/name","payload":{"userId":"10","name":""}} action

So, why do you expect "name":"" if the second action in this test case sets name to "Name"?

Logux received wrong-subprotocol error but test app does not sent any request

When I try to execute @logux/backend-test I got LoguxError but the backend server actually does not receive any requests.

lbt git:(next) ✗ npx @logux/backend-test http://127.0.0.1:8000/logux/
Protocol version: 4
Secret:           parole
Logux server:     http://localhost:31337/
Back-end server:  http://127.0.0.1:8000/logux/0 Supports token authentication

Re-run test: npx @logux/backend-test http://127.0.0.1:8000/logux/ 0

LoguxError: Logux received wrong-subprotocol error (Only 0.0.0 application subprotocols are supported, but you use 1.0.0)
    at ClientNode.syncError (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/base-node/index.cjs:220:15)
    at ClientNode.errorMessage (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/error/index.cjs:10:8)
    at ClientNode.onMessage (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/base-node/index.cjs:193:27)
    at /Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/base-node/index.cjs:88:14
    at Object.emit (/Users/egregors/Documents/GitHub/django/lbt/node_modules/nanoevents/index.cjs:5:7)
    at Timeout._onTimeout (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/local-pair/index.cjs:59:30)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

How should I make brute force protection to satisfy this tests?

I'm writing PHP backend for Logux.
My brute force protection prevents trying to log in for 60 seconds after 5 attempts with wrong secret.
Brute force test passes but following test fails due to brute force prevention mechanism.
Any advice on how to make this work?

Propositions for enhancement

I believe logix-backend-test could make the development process much easier but some points look confusing for now.

This is a few problems I got during adding proto4 support according to Spec + backend-test:

  • Every test should be represented in the Readme like a separate step
  • Step / Test number should match the number of step description in Readme
  • Steps description in Readme should be in the same order as in the tests
  • Every step should contain a link to the documentation if it necessary
  • We need to decide how to be with the backend persistent state during the tests. Looks like backend-test expect DB wipe every step. It seems unusual if we are running them like integration tests. I mean, it's OK, if we run each test separated. But otherwise, when all tests run at once, each next test does not expect state changes made by the previous tests.

Can't pass wrongSubprotocol error assert

Step 6 "Checks users subprotocol"

I find error format in the Spec: https://logux.io/protocols/backend/spec/

{
  "answer": "wrongSubprotocol",
  "supported": string
}

So, as the answer I sent:

2020-07-15 08:58:02,678 - logux.views - DEBUG - got auth cmd: {'command': 'auth', 'authId': 'rSecXfrA4Hdzf2s1RNK1E', 'userId': '10', 'token': '10:good', 'headers': {}, 'cookie': {}, 'subprotocol': '0.9.1'}
2020-07-15 08:58:02,679 - logux.core - WARNING - unsupported subprotocol version: 0.9.1 expected: ^1.0.0
2020-07-15 08:58:02,679 - logux.views - DEBUG - {'answer': 'wrongSubprotocol', 'supported': '^1.0.0'}

But backend-test expect something like (@logux/backend-test/tests/auth.js:61): '^1.0.0 application subprotocols are supported, but you use 0.9.1', so I got error as result:

Re-run test: npx @logux/backend-test http://localhost:8000/logux/ 6

Error: Wrong credentials
    at /Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/server/test-client/index.js:51:18
    at Object.emit (/Users/egregors/Documents/GitHub/django/lbt/node_modules/nanoevents/index.cjs:5:7)
    at ClientNode.syncError (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/base-node/index.cjs:221:18)
    at ClientNode.errorMessage (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/error/index.cjs:10:8)
    at ClientNode.onMessage (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/base-node/index.cjs:193:27)
    at /Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/base-node/index.cjs:88:14
    at Object.emit (/Users/egregors/Documents/GitHub/django/lbt/node_modules/nanoevents/index.cjs:5:7)
    at Timeout._onTimeout (/Users/egregors/Documents/GitHub/django/lbt/node_modules/@logux/core/local-pair/index.cjs:59:30)
    at listOnTimeout (internal/timers.js:551:17)
    at processTimers (internal/timers.js:494:7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.