Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Rajeev Barde
    @rajeevbarde
    hi, chakram still maintained ?
    Walter Hector Lijo
    @woolter
    @rajeevbarde Chakram is no longer actively maintained, PRs are welcomed
    manudee
    @manudee

    Does anyone know how to extract access_token and refresh_token from CookieJar within a response object?
    I have a following response object(after using chakram.post):

     body:
       { header:
          { messageType: *somevalue*,
            apiVersion: *somevalue*,
            sendingTime: *somevalue* },
         payload: { message: [Object] },
         trailer: { checkSum: *somenumber* } },
      jar:
       RequestJar {
         _jar:
          CookieJar {
            enableLooseMode: true,
            store: { idx: { *somepathvalue*:
       { *basePath*:
          { access_token: Cookie="access_token=*valueofAccessToken*+; Expires='Date' GMT; Max-Age=5184000; Path=*basePath*; Secure; HttpOnly; hostOnly=true; aAge=234ms; cAge=234ms" },
         *someNewPathValue*:
          { refresh_token: Cookie="refresh_token=*valueofRefreshToken*; Expires='Date'; Max-Age=5184000; Path=*someNewPathValue*; Secure; HttpOnly; hostOnly=true; aAge=235ms; cAge=235ms" } } } } } },
      url: *pathToAuthUrl*,
      responseTime: *somevalue* }

    I am trying to retrieve access_token and refresh token so I can reuse it for my subsequent requests
    to get the data back.
    I traversed the response object using object dot notation as below

      ```
              console.log((apiResponse.jar._jar.store.idx['somepathvalue']['basePath']));
                console.log((apiResponse.jar._jar.store.idx['somepathvalue']['basePath'].access_token));
                console.log((apiResponse.jar._jar.store.idx['somepathvalue']['someNewPathValue'].refresh_token));
            ```

    However, they don't give me the exact value of the access token and refresh token yet. I tried using tough-cookie npm but had no luck.
    Any ideas, how should I proceed? Thanks in advance.

    Walter Hector Lijo
    @woolter
    @manudee can you post an example of the response? As I can see what are you doing is ok, but without a working example I cannot help you
    manudee
    @manudee
    @woolter here u go. I am trying to retrieve the access token as below using the dot notation (resp object as i mentioned above). However the console logs give me the entire string starting from the "Cookie=" . How would get the "valueofAccessToken" ?
    it('should retrieve the access token', function(){
    
    var loginDataPositive = {
                        "email": testData.email,
                        "password": testData.password,
                        "scope": testData.scope
    
                    };
    
    
        return chakram.post(config.url + '/auth/token', loginDataPositive)
                    .then(function(response){    
    
                        console.log("token ");
                        console.log((response.jar._jar.store.idx['somepathvalue]['basePath'].access_token));
                        console.log((response.jar._jar.store.idx['somepathvalue]['someNewPathValue'].refresh_token));
    
                        chakram.setRequestDefaults({jar:true});
    
                        })
    
    
    })
    Walter Hector Lijo
    @woolter
    @manudee in the console are you this Cookie="access_token=*valueofAccessToken*+; Expires='Date' GMT; Max-Age=5184000; Path=*basePath*; Secure; HttpOnly; hostOnly=true; aAge=234ms; cAge=234ms"
    If the answer is yes, it works as expected, after that you need to use a Regex to get what you want
    jain-neeeraj
    @jain-neeeraj
    @manudee easy way of doing it is by debugging your test case using --inspect command line parameter and then by trying to access the response object in browser console. That way you will be able to find out correct path to the key you are trying to retrive
    manudee
    @manudee
    @woolter Thanks. I do get the above value in the console. I will use regex now to extract the access token. Thanks a ton!
    Muhammad Omar Ahsan
    @m-omarahsan
    I am looking for a way to pass URL params in chakram request but seems like there is no way i could pass the parameters required in the URL.
    For example.
    image.png
    image.png
    Walter Hector Lijo
    @woolter
    @m-omarahsan I don't know about what params are you talking about ({{host}} or query parameters) anyway you can create the url before GET, programmatically you can do whatever you want
    if you need help just ask
    bharukaRupesh
    @bharukaRupesh
    Hi,
    can anyone please suggest utility to generate test report of chakram?
    Walter Hector Lijo
    @woolter
    @bharukaRupesh mochawesome
    Walter Hector Lijo
    @woolter
    Have you mocha installed globally?
    Walter Hector Lijo
    @woolter
    I can't understand what dow you need to configure inmochawesome
    bharukaRupesh
    @bharukaRupesh

    @woolter What I mean to say is, I am using below command to generate the report,
    mocha .\test.js --reporter mochawesome --reporter-options reportFilename="tssp-api-automation", reportTitle="TSSP API Automation Report",autoOpen=true

    You can see above various parameters I have passed for report. Instead of passing this through command line, how can we configure it in a file?

    I hope it is clear now.

    bharukaRupesh
    @bharukaRupesh

    can anyone help me in knowing how to pass headers data to chakram.post( )?
    I tried using below code but it's not working,

    chakram.post("https://xyz.com/logout", { }, {headers:{
    'content-type':'application/json',
    Cookie:jsessionId,
    'X-XSRF-TOKEN':token
    }});

    Walter Hector Lijo
    @woolter
    @bharukaRupesh I think that here you have all the information that you need https://adamgruber.github.io/mochawesome/
    at the end
    Walter Hector Lijo
    @woolter
    describe("Lookback API", function () {
      var options = {
        headers: {
          'content-type': 'application/json',
          authorization: 'Basic <hash>',
          test:"tt"
        },
        body: {
          projects: [23112780161],
          release: 27036212139,
          features: [33016599886],
          includeUnparented: true
        },
        json: true
      };
      it("The aggregation point should return data", function () {
        var response = chakram.post('https://httpbin.org/post', "", options);
        expect(response).to.have.status(200);
        expect(response).to.have.json('headers.Authorization', 'Basic <hash>');
        expect(response).to.have.json(function(json) {
          console.log(json);
        });
        return chakram.wait();
      });
    });
    this is the code that dareid wrote in the post that I send to you
    bharukaRupesh
    @bharukaRupesh
    Thanks @woolter
    Given things have worked for me.
    bharukaRupesh
    @bharukaRupesh
    Hi All,
    As I am novice to chakram I want to know that "is chakram tool still maintained by the official committee?"
    OR
    is it good to go with the chakram tool for api automation?
    I am asking this because I could not find examples or reference material. As some of you are already aware of it, you can share your experience with the tool.
    Walter Hector Lijo
    @woolter
    @bharukaRupesh First at all you need to reed .... xD Chakram is no longer actively maintained, PRs are welcomed this is the second line in the repo https://github.com/dareid/chakram/
    If is good to go it's up to you, I was using chakram for a long time for me is an amazing tool. Anyway in the last project that I've started I didn't use it.
    bharukaRupesh
    @bharukaRupesh
    Thanks @woolter for your kind response.
    rookieInTraining
    @rookieInTraining
    Hi Everyone, need some info regarding chakram expectations
    I need to compare the responses of two different REST APIs and ensure that the responses do not have the same content
    In order to do that, I'm resolving the promises and then expecting that the two fields are not equal
    var eng = chakram.get(browser.baseUrl);
                expect(eng).to.have.status(200);
                var response = chakram.get(browser.baseUrl + locale);
                expect(response).to.have.status(200);
    
                var engRes = eng.then((res1) => {
                    return res1.body;
                }).then((json) => {
                    var res = response.then((res2) => {
                        expect(res2.body.shortDaysTranslation.wed).to.equal(json.shortDaysTranslation.wed);
                    });
                });
    This code should fail, but it is not failing.. any thoughts?
    Venkat413
    @Venkat413
    @bharukaRupesh u are not resolving the promise here. Do the below thing. might help var response = chakram.post('https://httpbin.org/post', "", options).then(function(data){ your code})
    Venkat413
    @Venkat413
    @rookieInTraining resolve the promise and save the responses RESP1 & RESP2. Then use the chai assertions to compare the objects.
    rookieInTraining
    @rookieInTraining
    Thanks @Venkat413
    Venkat413
    @Venkat413
    any idea of generating the bearer token and use for multiple requests
    jain-neeeraj
    @jain-neeeraj
    @Venkat413 generate it in before block and use it in the it blocks
    Venkat413
    @Venkat413
    @jain-neeeraj Thanks jain. i have tried the same way. Any possibilities u can share with code sample. Using the before/http Authentication. Thanks in advance
    Venkat413
    @Venkat413
    How to execute multiple test cases with a single function. Any ideas
    hitesh-jani
    @hitesh-jani
    Hey guys
    i am starting with api testing
    which library would be better chakram or frisby ?
    can anyone suggest me please?
    jain-neeeraj
    @jain-neeeraj
    @hitesh-jani chakram is a very easy to use library, though it is not actively maintained but should be able to solve most of your problems.
    ajsea
    @agaly
    hi guys can I use Chakram to test API's built with springboot and not nodejs
    jain-neeeraj
    @jain-neeeraj
    @agaly you can hit any REST API with chakram but chakram itself runs on nodejs
    philicia
    @tirzahtoh_twitter
    Hi I am new to this framework, can I have a simple example to get started? thanks
    how do I run the test?
    philicia
    @tirzahtoh_twitter
    Hi I got this error 1) API Testing for voice input
    "before all" hook: login for "should return 200 on success":
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/tohlaymui/Desktop/tl_stella-API_test/src/testapp/test/login.test.js)