← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~ilasc/launchpad:revision-status-submission-api into launchpad:master

 


Diff comments:

> diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
> index a832554..3c99c17 100644
> --- a/lib/lp/code/model/tests/test_gitrepository.py
> +++ b/lib/lp/code/model/tests/test_gitrepository.py
> @@ -4200,6 +4208,44 @@ class TestGitRepositoryWebservice(TestCaseWithFactory):
>              self.assertEqual(
>                  InformationType.PUBLIC, repository_db.information_type)
>  
> +    def test_newRevisionStatusReport(self):
> +        repository = self.factory.makeGitRepository()
> +        requester = repository.owner
> +        with person_logged_in(requester):
> +            repository_url = api_url(repository)
> +        webservice = webservice_for_person(
> +            requester, permission=OAuthPermission.WRITE_PUBLIC,
> +            default_api_version="devel")
> +        response = webservice.named_post(
> +            repository_url, "issueAccessToken", description="Test token",
> +            scopes=["repository:build_status"])
> +        self.assertEqual(200, response.status)
> +        secret = response.jsonBody()
> +        with person_logged_in(requester):
> +            token = getUtility(IAccessTokenSet).getBySecret(secret)
> +            self.assertThat(token, MatchesStructure(
> +                owner=Equals(requester),
> +                description=Equals("Test token"),
> +                target=Equals(repository),
> +                scopes=Equals([AccessTokenScope.REPOSITORY_BUILD_STATUS]),
> +                date_expires=Is(None)))
> +        # Use the token to create a new Status Report
> +        with person_logged_in(requester):
> +            repository_url = api_url(repository)
> +        webservice = webservice_for_person(
> +            requester, permission=OAuthPermission.WRITE_PRIVATE,
> +            default_api_version="devel")
> +
> +        # header = "Authorization: Token %s" % token
> +        header = {'Authorization-type': 'Token %s' % token}

The header name should be "Authorization", not "Authorization-type".

You also need to pass the `secret` in the Authorization header, not a stringified version of an `AccessToken` object.  I suspect that's the problem you were having ...

> +        response = webservice.named_post(
> +            repository_url, "newRevisionStatusReport",
> +            headers=header, name="CI", status="Queued",
> +            description="120/120 tests passed",
> +            commit_sha1='823748ur9804376', result='Success')
> +
> +        self.assertEqual(200, response.status)
> +
>      def test_set_target(self):
>          # The repository owner can move the repository to another target;
>          # this redirects to the new location.


-- 
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/410373
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:revision-status-submission-api into launchpad:master.



References