<commit_before>--TEST--
OAuth getRequestToken
--SKIPIF--
<?php
require 'skip.inc';
skip_if_not_php_major(5);
skip_with_bug(44603);
require 'server.inc';
http_server_skipif('tcp://127.0.0.1:12342');
?>
--FILE--
<?php
require 'server.inc';

$x = new OAuth('1234','1234');
$x->setRequestEngine(OAUTH_REQENGINE_STREAMS);

$pid = http_server("tcp://127.0.0.1:12342", array(
	"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1<PASSWORD>&oauth_token_secret=4567",
	"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567",
	"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567",
), $output);

$x->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
var_dump($x->getRequestToken('http://127.0.0.1:12342/test'));

$x->setAuthType(OAUTH_AUTH_TYPE_FORM);
var_dump($x->getRequestToken('http://127.0.0.1:12342/test'));

$x->setAuthType(OAUTH_AUTH_TYPE_URI);
var_dump($x->getRequestToken('http://127.0.0.1:12342/test'));

fseek($output, 0, SEEK_SET);
var_dump(stream_get_contents($output));

http_server_kill($pid);

?>
--EXPECTF--
array(2) {
  ["oauth_token"]=>
  string(4) "1234"
  ["oauth_token_secret"]=>
  string(4) "4567"
}
array(2) {
  ["oauth_token"]=>
  string(4) "1234"
  ["oauth_token_secret"]=>
  string(4) "4567"
}
array(2) {
  ["oauth_token"]=>
  string(4) "1234"
  ["oauth_token_secret"]=>
  string(4) "4<PASSWORD>"
}
string(%d) "GET /test HTTP/%f
Host: 127.0.0.1:12342
Authorization: OAuth oauth_consumer_key="1234",oauth_signature_method="HMAC-SHA1",oauth_nonce="%s.%d",oauth_timestamp="%d",oauth_version="1.0",oauth_signature="%s"

POST /test HTTP/%f
Host: 127.0.0.1:12342
Content-Length: %d
Content-Type: application/x-www-form-urlencoded

oauth_consumer_key=1234&oauth_signature_method=HMAC-SHA1&oauth_nonce=%s.%d&oauth_timestamp=%d&oauth_version=1.0&oauth_signature=%s
GET /test?oauth_consumer_key=1234&oauth_signature_method=HMAC-SHA1&oauth_nonce=%s.%d&oauth_timestamp=%d&oauth_version=1.0&oauth_signature=%s HTTP/%f
Host: 127.0.0.1:12342

"<commit_msg>fixing the timestamp and nonce for better testing<commit_after>--TEST--
OAuth getRequestToken
--SKIPIF--
<?php
require 'skip.inc';
skip_if_not_php_major(5);
skip_with_bug(44603);
require 'server.inc';
http_server_skipif('tcp://127.0.0.1:12342');
?>
--FILE--
<?php
require 'server.inc';

$x = new OAuth('1234','1234');
$x->setRequestEngine(OAUTH_REQENGINE_STREAMS);
$x->setTimestamp(12345);
$x->setNonce('testing');

$pid = http_server("tcp://127.0.0.1:12342", array(
	"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=<PASSWORD>&oauth_token_secret=<PASSWORD>",
	"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=<PASSWORD>&oauth_token_secret=4567",
	"HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 40\r\n\r\noauth_token=1234&oauth_token_secret=4567",
), $output);

$x->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
var_dump($x->getRequestToken('http://127.0.0.1:12342/test'));

$x->setAuthType(OAUTH_AUTH_TYPE_FORM);
var_dump($x->getRequestToken('http://127.0.0.1:12342/test'));

$x->setAuthType(OAUTH_AUTH_TYPE_URI);
var_dump($x->getRequestToken('http://127.0.0.1:12342/test'));

fseek($output, 0, SEEK_SET);
var_dump(stream_get_contents($output));

http_server_kill($pid);

?>
--EXPECTF--
array(2) {
  ["oauth_token"]=>
  string(4) "1234"
  ["oauth_token_secret"]=>
  string(4) "4567"
}
array(2) {
  ["oauth_token"]=>
  string(4) "1234"
  ["oauth_token_secret"]=>
  string(4) "4567"
}
array(2) {
  ["oauth_token"]=>
  string(4) "1234"
  ["oauth_token_secret"]=>
  string(4) "4567"
}
string(%d) "GET /test HTTP/%f
Host: 127.0.0.1:12342
Authorization: OAuth oauth_consumer_key="1234",oauth_signature_method="HMAC-SHA1",oauth_nonce="testing",oauth_timestamp="12345",oauth_version="1.0",oauth_signature="1LrorB42HWTcTi8M4NUVWsfZgqE%3D"

POST /test HTTP/%f
Host: 127.0.0.1:12342
Content-Length: %d
Content-Type: application/x-www-form-urlencoded

oauth_consumer_key=1234&oauth_signature_method=HMAC-SHA1&oauth_nonce=testing&oauth_timestamp=12345&oauth_version=1.0&oauth_signature=pwOAI3vHnKHd%2FLUYcJOr36Ed5Vg%3D
GET /test?oauth_consumer_key=1234&oauth_signature_method=HMAC-SHA1&oauth_nonce=testing&oauth_timestamp=12345&oauth_version=1.0&oauth_signature=1LrorB42HWTcTi8M4NUVWsfZgqE%3D HTTP/%f
Host: 127.0.0.1:12342

"
{'fraction_non_alphanumeric': 0.1937457511896669, 'fraction_numerical': 0.09607976433265353, 'mean_word_length': 7.099082568807339, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 16, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6854247', 'n_tokens_mistral': 2150, 'n_tokens_neox': 1919, 'n_words': 201}