Forum Discussion

vikititor's avatar
vikititor
Contributor
4 years ago
Solved

OAuth token value in AuthManager update form test (groovy)

Hello all, 

I am using AuthManager in my project. But unfortunetally we implemented new dynamic part of the token. So I must refresh it after each new deployment. So for CI/CD is problem.

In my AuthManager I have token value. Now I can send my HTTP to get new one.. But remains question, how to update the value in AuthManager?

 

Any ideas? I saw some examples with update of the use name, etc.. but somehow this is not aplicable for me. 
I need just update the token value.

 

I dont know the object model.. And form some reason the ReadyAPI groovy step does not help me with syntax:

import com.eviware.soapui.config.AuthEntryTypeConfig;

def project = testRunner.getTestCase().getTestSuite().getProject();
def authProfile = project.getAuthRepository().getEntry("Name of your profile");

So  I have no idea what are all the available variables and methods in authProfile ...

 

Any idea wellcomed.

  • def authContainer = testRunner.testCase.testSuite.project.OAuth2ProfileContainer
    def authProfile = authContainer.getProfileByName("admin_default")
    def oldToken = authProfile.getAccessToken();
    log.info oldToken;
    // updated
    authProfile.setAccessToken("some");
    log.info authProfile.getAccessToken();

     

    Can anybody tell me, why the helper dont know the setAccessToken method? When I am typing the code in groovy step?

    I just found it by my sugesstion.. But IT MUST be somewhere descripted.. Like in object mode.. but I did not found it there..

    It works.. but is stranght, that this was done by gessing...

3 Replies

  • def authContainer = testRunner.testCase.testSuite.project.OAuth2ProfileContainer
    def authProfile = authContainer.getProfileByName("admin_default")
    def oldToken = authProfile.getAccessToken();
    log.info oldToken;
    // updated
    authProfile.setAccessToken("some");
    log.info authProfile.getAccessToken();

     

    Can anybody tell me, why the helper dont know the setAccessToken method? When I am typing the code in groovy step?

    I just found it by my sugesstion.. But IT MUST be somewhere descripted.. Like in object mode.. but I did not found it there..

    It works.. but is stranght, that this was done by gessing...

    • richie's avatar
      richie
      Community Hero
      Hey vikititor,

      I cant answer your question, but just wanted to say thanks for answering your query so quickly....i'm gonna completely steal your code for my own use, so thanks a lot! ๐Ÿ˜‰

      Rich
      • vikititor's avatar
        vikititor
        Contributor

        Problem is, that is nowhere descripted.. the object model of ReadyAPI does not know the class neighter the methods.

         

        I think, this is the problem.. I want to do something, but how??? :-DDD

        I just tryed many variants.. and this works.. 

        BTW the include rows are not necessary..