def test_simple_stmt_get_mine_only(self):
        guid = str(uuid.uuid1())
        # Put statement normally
        username = "tester1"
        email = "test1@tester.com"
        password = "test"
        auth = "Basic %s" % base64.b64encode("%s:%s" % (username, password))
        form = {"username":username, "email":email,"password":password,"password2":password}
        self.client.post(reverse(register),form, X_Experience_API_Version=settings.XAPI_VERSION)
        self.client.logout()

        param = {"statementId":guid}
        path = "%s?%s" % (reverse('lrs:statements'), urllib.urlencode(param))
        stmt = json.dumps({"verb":{"id": "http://example.com/verbs/passed","display": {"en-US":"passed"}},
            "object": {"id":"act:test_put"},"actor":{"objectType":"Agent", "mbox":"mailto:t@t.com"}})

        put_resp = self.client.put(path, stmt, content_type="application/json", Authorization=auth, X_Experience_API_Version=settings.XAPI_VERSION)
        self.assertEqual(put_resp.status_code, 204)
        
        param = {"statementId":guid}
        path = "%s?%s" % ('http://testserver/XAPI/statements', urllib.urlencode(param))
        # ====================================================

        oauth_header_resource_params, access_token = self.oauth_handshake(scope_type="statements/read/mine")

        # 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

        resp = self.client.get(path, Authorization=oauth_header_resource_params, X_Experience_API_Version=settings.XAPI_VERSION)
        self.assertEqual(resp.status_code, 403)
        # ===================================================

        # build stmt data and path
        oauth_agent1 = Agent.objects.get(account_name=self.consumer.key)
        oauth_agent2 = Agent.objects.get(mbox="mailto:test1@tester.com")
        oauth_group = Agent.objects.get(member__in=[oauth_agent1, oauth_agent2])
        guid = str(uuid.uuid1())

        stmt_data = {"id":guid,"actor":{"objectType": "Agent", "mbox":"mailto:t@t.com", "name":"bill"},
            "verb":{"id": "http://example.com/verbs/accessed","display": {"en-US":"accessed"}},
            "object": {"id":"act:test_put"}, "authority":oauth_group.to_dict()}
        
        settings.ALLOW_EMPTY_HTTP_AUTH = True

        stmt_post = self.client.post(reverse('lrs:statements'), json.dumps(stmt_data), content_type="application/json",
            Authorization="Basic %s" % base64.b64encode("%s:%s" % ('','')), X_Experience_API_Version=settings.XAPI_VERSION)
        self.assertEqual(stmt_post.status_code, 200)

        param = {"statementId":guid}
        path = "%s?%s" % ('http://testserver/XAPI/statements', urllib.urlencode(param))

        # Use same oauth headers but replace the nonce 
        oauth_header_resource_params_dict['oauth_nonce'] = 'get_differ_nonce'

        # Create another oauth request, replace the signature with new one and change the nonce
        oauth_request2 = oauth.Request.from_token_and_callback(access_token, http_method='GET',
            http_url=path, parameters=oauth_header_resource_params_dict)
        signature_method2 = oauth.SignatureMethod_HMAC_SHA1()
        signature2 = signature_method2.sign(oauth_request2, self.consumer, access_token)
        sig = oauth_header_resource_params.replace('"%s"' % signature, '"%s"' % signature2)
        new_oauth_headers = sig.replace('oauth_nonce="resource_nonce"','oauth_nonce="get_differ_nonce"')        

        get = self.client.get(path, content_type="application/json",
            Authorization=new_oauth_headers, X_Experience_API_Version=settings.XAPI_VERSION)
        self.assertEqual(get.status_code, 200)
        settings.ALLOW_EMPTY_HTTP_AUTH = False
dataset/ETHPy150Open adlnet/ADL_LRS/lrs/tests/test_OAuth.py/OAuthTests.test_simple_stmt_get_mine_only/original