Karate software - uploading files to Gitlab via Karate (permission problem)

Viewed 45

Using Karate I need to upload some files to Gitlab but I am not successful. I have no idea how to handle credentials to be able to connect to the Git lab. I have tried to use this:

Given url 'https://gitlab.xxxx.xxxxx.com/projectX/client-data-service'
And multipart file file = { read: 'test.jpg', filename:'test.jpg', contentType: 'image/jpg' }
When method post
Then status 200

Then I have tried to use login to gitlab via driver in the beginning (to be logged in):

Given driver 'https://gitlab.xxxx.xxxxx.com/users/sign_in'
* retry().input('input[id=user_login]', 'user@user.xx')
* retry().input('input[id=user_password]', '12345')
* retry().click('input[name=commit]')
* delay(3000);
Given driver 'https://gitlab.xxxx.xxxxx.com/projectX/client-data-service'
* delay(3000);

Given url 'https://gitlab.xxxx.xxxxx.com/projectX/client-data-service'
And multipart file file = { read: 'test.jpg', filename:'test.jpg', contentType: 'image/jpg' }
When method post
Then status 200

but I still receive information about permission problem:

<div class="container">
    <h3>The page could not be found or you don't have permission to view it.</h3>
    <hr />
    <p>The resource that you are attempting to access does not exist or you don't have the necessary permissions to view it.</p>
    <p>Make sure the address is correct and that the page hasn't moved.</p>
    <p>Please contact your GitLab administrator if you think this is a mistake.</p>
    <a href="javascript:history.back()" class="js-go-back go-back">Go back</a>
  </div>

Could you have some idea to be successful with uploading file(s) to Gitlab/Github with permission? Thank you!

1 Answers

I suggest the API. You have to understand how to pass GitLab credentials by reading the docs here: https://docs.gitlab.com/ee/api/README.html#authentication

I'm sorry I can't help more than that. Note that there are examples of auth and even OAuth in the demos. Maybe you just need to add a header with the private / access-token. Try getting a cURL command to work first, and then porting that to Karate should be easy.

Related