Git Product home page Git Product logo

Comments (10)

vlucas avatar vlucas commented on August 29, 2024 1

Try using inspectRequest() to ensure that the header values are getting passed correctly, and are the values that you expect.

from frisby.

G4gan avatar G4gan commented on August 29, 2024 1

Thanks.
It worked adding above globaSetup().
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

from frisby.

G4gan avatar G4gan commented on August 29, 2024

Thanks @vlucas.
If you have read my comment. My test is getting passed even when expect checks for status 200 and provided is 400. And my token is not getting generated in either case.
I tried inspectBody(),inspectJson() also inspectrequest(). None worked.
If you can tell is there anything else I need to change in my code.
I am following this link:
https://docs.frisbyjs.com/api-and-usage/setup

from frisby.

LarryBattleWork avatar LarryBattleWork commented on August 29, 2024

Your curl command disables HTTPS cert checking with the -k flag.
So maybe you need to do the same in the frisby test.
Just guessing but maybe you should add the node-fetch options to disable HTTPS cert checking.
Try this.

var frisby = require('frisby');
frisby.globalSetup({
    request: {
        headers: {
            'Authorization': 'Basic ' + Buffer.from("username:password").toString('base64'),
            'header':'value'
        },
        // It's one of these
        strictSSL : false,
        rejectUnauthorized: false
    } 
});

//do setup for Authorization of the token for REST call
it ('uses globalSetup for every test after it is called', function () {
    return frisby.get('URL')
        .inspectResponse()
        .expect('status', 400);
});

from frisby.

G4gan avatar G4gan commented on August 29, 2024

@LarryBattleWork
Getting error when passing either of strictSSL : false, rejectUnauthorized: false in globalSetup()
Failures:
FetchError: request to http://URL/login failed, reason: socket hang up
Stack:
error properties: null({ type: 'system', errno: 'ECONNRESET', code: 'ECONNRESET', constructor: Function })
at
at ClientRequest. (dir\node_modules\node-fetch\lib\index.js:1455:11)
at ClientRequest.emit (events.js:310:20)

from frisby.

LarryBattleWork avatar LarryBattleWork commented on August 29, 2024

So your solution looks like this?

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

frisby.globalSetup({
    request: {
        headers: {
            'Authorization': 'Basic ' + Buffer.from("username:password").toString('base64'),
            'header':'value'
        }
    } 
});

NOTE: Don't use NODE_TLS_REJECT_UNAUTHORIZED in production code.
Doc link: https://nodejs.org/api/cli.html#cli_node_tls_reject_unauthorized_value

from frisby.

G4gan avatar G4gan commented on August 29, 2024

@LarryBattleWork thanks for response.
Can you suggest other property other than this which will work.
I tried
strictSSL : false,
rejectUnauthorized: false
Both seems to not work.

Also how can I get the response in variable.
I tried
.then(function (res) {
let postId = res.json;
Console.log(postId)
}
But this seems to give error.
Any suggestions.

from frisby.

H1Gdev avatar H1Gdev commented on August 29, 2024

If curl -k option is removed, does it give an error like frisby ?

from frisby.

G4gan avatar G4gan commented on August 29, 2024

@H1Gdev
-k in curl is for verifying server legitimacy.
so in that case it error me with ssl error.

from frisby.

G4gan avatar G4gan commented on August 29, 2024

@vlucas Can you please suggest which reporting goes with Jasmine-Frisby project.
Or if any links yo can refer me too.

Thanks in advance.

from frisby.

Related Issues (20)

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.