def test_request_token_same_nonce_and_time(self):
        # Nonce/timestamp/token combo should always be unique
        # Header params we're passing in
        now_time = str(int(time.time()))
        oauth_header_request_token_params = "OAuth realm=\"test\","\
               "oauth_consumer_key=\"%s\","\
               "oauth_signature_method=\"HMAC-SHA1\","\
               "oauth_timestamp=\"%s\","\
               "oauth_nonce=\"requestnonce\","\
               "oauth_version=\"1.0\","\
               "oauth_callback=\"http://example.com/request_token_ready\"" % (self.consumer.key, now_time)

        # Make string params into dictionary for from_consumer_and_token function
        request_token_param_list = oauth_header_request_token_params.split(",")
        oauth_header_request_token_params_dict = {}
        for p in request_token_param_list:
            item = p.split("=")
            oauth_header_request_token_params_dict[str(item[0]).strip()] = str(item[1]).strip('"')
        
        # get_oauth_request in views ignores realm, must remove so not input to from_token_and_callback
        del oauth_header_request_token_params_dict['OAuth realm']

        # add scope to the existing params
        oauth_request = oauth.Request.from_consumer_and_token(self.consumer, token=None, http_method='GET',
            http_url=INITIATE_ENDPOINT, parameters=oauth_header_request_token_params_dict)
        
        # create signature and add it to the header params
        signature_method = oauth.SignatureMethod_HMAC_SHA1()
        signature = signature_method.sign(oauth_request, self.consumer, None)
        oauth_header_request_token_params = oauth_header_request_token_params + ",oauth_signature=%s" % signature
        
        request_resp = self.client.get(INITIATE_ENDPOINT, Authorization=oauth_header_request_token_params)
        self.assertEqual(request_resp.status_code, 200)
        # ========================================

        # Try to create another request token with the same nonce
        # Header params we're passing in
        oauth_header_request_token_params2 = "OAuth realm=\"test\","\
               "oauth_consumer_key=\"%s\","\
               "oauth_signature_method=\"HMAC-SHA1\","\
               "oauth_timestamp=\"%s\","\
               "oauth_nonce=\"requestnonce\","\
               "oauth_version=\"1.0\","\
               "oauth_callback=\"http://example.com/request_token_ready\"" % (self.consumer.key, now_time)

        # Make string params into dictionary for from_consumer_and_token function
        request_token_param_list2 = oauth_header_request_token_params2.split(",")
        oauth_header_request_token_params_dict2 = {}
        for p in request_token_param_list2:
            item = p.split("=")
            oauth_header_request_token_params_dict2[str(item[0]).strip()] = str(item[1]).strip('"')
        
        # get_oauth_request in views ignores realm, must remove so not input to from_token_and_callback
        del oauth_header_request_token_params_dict2['OAuth realm']

        # add scope to the existing params
        oauth_request2 = oauth.Request.from_consumer_and_token(self.consumer, token=None, http_method='GET',
            http_url=INITIATE_ENDPOINT, parameters=oauth_header_request_token_params_dict2)
        
        # create signature and add it to the header params
        signature_method2 = oauth.SignatureMethod_HMAC_SHA1()
        signature2 = signature_method2.sign(oauth_request2, self.consumer, None)
        oauth_header_request_token_params2 = oauth_header_request_token_params2 + ",oauth_signature=%s" % signature2
        
        request_resp2 = self.client.get(INITIATE_ENDPOINT, Authorization=oauth_header_request_token_params2)
        self.assertEqual(request_resp2.status_code, 400)
dataset/ETHPy150Open adlnet/ADL_LRS/lrs/tests/test_OAuth.py/OAuthTests.test_request_token_same_nonce_and_time/original