def test_profile_wrong_auth(self):
        agent = Agent(name="joe", mbox="mailto:joe@example.com")
        agent.save()

        # Agent is not in this auth
        url = 'http://testserver/XAPI/agents/profile'
        testparams = {"agent": '{"name":"joe","mbox":"mailto:joe@example.com"}'}
        path = '%s?%s' % (url, urllib.urlencode(testparams))

        oauth_header_resource_params, access_token = self.oauth_handshake(scope_type='profile')

        # from_token_and_callback takes a dictionary        
        param_list = oauth_header_resource_params.split(",")
        oauth_header_resource_params_dict = {}
        for p in param_list:
            item = p.split("=")
            oauth_header_resource_params_dict[str(item[0]).strip()] = str(item[1]).strip('"')
        # from_request ignores realm, must remove so not input to from_token_and_callback
        del oauth_header_resource_params_dict['OAuth realm']
        
        # Create oauth request and add signature
        oauth_request = oauth.Request.from_token_and_callback(access_token, http_method='GET',
            http_url=path, parameters=oauth_header_resource_params_dict)
        signature_method = oauth.SignatureMethod_HMAC_SHA1()
        signature = signature_method.sign(oauth_request, self.consumer, access_token)
        oauth_header_resource_params += ',oauth_signature="%s"' % signature

        get = self.client.get(path, content_type="application/json",
            Authorization=oauth_header_resource_params, X_Experience_API_Version=settings.XAPI_VERSION)
        self.assertEqual(get.status_code, 403)
        self.assertEqual(get.content, "Authorization doesn't match agent in profile")
dataset/ETHPy150Open adlnet/ADL_LRS/lrs/tests/test_OAuth.py/OAuthTests.test_profile_wrong_auth/original