|
|
@ -36,59 +36,50 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ |
|
|
|
'dummy_method', |
|
|
|
'dummy_method', |
|
|
|
$deadline); |
|
|
|
$deadline); |
|
|
|
$tag = 1; |
|
|
|
$tag = 1; |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$call->invoke($this->client_queue, $tag, $tag); |
|
|
|
$call->invoke($this->client_queue, |
|
|
|
|
|
|
|
$tag, |
|
|
|
|
|
|
|
$tag)); |
|
|
|
|
|
|
|
$server_tag = 2; |
|
|
|
$server_tag = 2; |
|
|
|
|
|
|
|
|
|
|
|
$call->writes_done($tag); |
|
|
|
$call->writes_done($tag); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertEquals(Grpc\OP_OK, $event->data); |
|
|
|
$this->assertSame(Grpc\OP_OK, $event->data); |
|
|
|
|
|
|
|
|
|
|
|
// check that a server rpc new was received |
|
|
|
// check that a server rpc new was received |
|
|
|
$this->server->request_call($server_tag); |
|
|
|
$this->server->request_call($server_tag); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type); |
|
|
|
$this->assertSame(Grpc\SERVER_RPC_NEW, $event->type); |
|
|
|
$server_call = $event->call; |
|
|
|
$server_call = $event->call; |
|
|
|
$this->assertNotNull($server_call); |
|
|
|
$this->assertNotNull($server_call); |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->server_accept($this->server_queue, $server_tag); |
|
|
|
$server_call->server_accept($this->server_queue, |
|
|
|
|
|
|
|
$server_tag)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->server_end_initial_metadata(); |
|
|
|
$server_call->server_end_initial_metadata()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// the server sends the status |
|
|
|
// the server sends the status |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->start_write_status(Grpc\STATUS_OK, $status_text, $server_tag); |
|
|
|
$server_call->start_write_status(Grpc\STATUS_OK, |
|
|
|
|
|
|
|
$status_text, |
|
|
|
|
|
|
|
$server_tag)); |
|
|
|
|
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertEquals(Grpc\OP_OK, $event->data); |
|
|
|
$this->assertSame(Grpc\OP_OK, $event->data); |
|
|
|
|
|
|
|
|
|
|
|
// the client gets CLIENT_METADATA_READ |
|
|
|
// the client gets CLIENT_METADATA_READ |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type); |
|
|
|
$this->assertSame(Grpc\CLIENT_METADATA_READ, $event->type); |
|
|
|
|
|
|
|
|
|
|
|
// the client gets FINISHED |
|
|
|
// the client gets FINISHED |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\FINISHED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISHED, $event->type); |
|
|
|
$status = $event->data; |
|
|
|
$status = $event->data; |
|
|
|
$this->assertEquals(Grpc\STATUS_OK, $status->code); |
|
|
|
$this->assertSame(Grpc\STATUS_OK, $status->code); |
|
|
|
$this->assertEquals($status_text, $status->details); |
|
|
|
$this->assertSame($status_text, $status->details); |
|
|
|
|
|
|
|
|
|
|
|
// and the server gets FINISHED |
|
|
|
// and the server gets FINISHED |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\FINISHED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISHED, $event->type); |
|
|
|
$status = $event->data; |
|
|
|
$status = $event->data; |
|
|
|
|
|
|
|
|
|
|
|
unset($call); |
|
|
|
unset($call); |
|
|
@ -106,10 +97,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ |
|
|
|
'dummy_method', |
|
|
|
'dummy_method', |
|
|
|
$deadline); |
|
|
|
$deadline); |
|
|
|
$tag = 1; |
|
|
|
$tag = 1; |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$call->invoke($this->client_queue, $tag, $tag); |
|
|
|
$call->invoke($this->client_queue, |
|
|
|
|
|
|
|
$tag, |
|
|
|
|
|
|
|
$tag)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$server_tag = 2; |
|
|
|
$server_tag = 2; |
|
|
|
|
|
|
|
|
|
|
@ -117,75 +105,68 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{ |
|
|
|
$call->start_write($req_text, $tag); |
|
|
|
$call->start_write($req_text, $tag); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type); |
|
|
|
$this->assertSame(Grpc\WRITE_ACCEPTED, $event->type); |
|
|
|
|
|
|
|
|
|
|
|
// check that a server rpc new was received |
|
|
|
// check that a server rpc new was received |
|
|
|
$this->server->request_call($server_tag); |
|
|
|
$this->server->request_call($server_tag); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\SERVER_RPC_NEW, $event->type); |
|
|
|
$this->assertSame(Grpc\SERVER_RPC_NEW, $event->type); |
|
|
|
$server_call = $event->call; |
|
|
|
$server_call = $event->call; |
|
|
|
$this->assertNotNull($server_call); |
|
|
|
$this->assertNotNull($server_call); |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->server_accept($this->server_queue, $server_tag); |
|
|
|
$server_call->server_accept($this->server_queue, |
|
|
|
|
|
|
|
$server_tag)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->server_end_initial_metadata(); |
|
|
|
$server_call->server_end_initial_metadata()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// start the server read |
|
|
|
// start the server read |
|
|
|
$server_call->start_read($server_tag); |
|
|
|
$server_call->start_read($server_tag); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\READ, $event->type); |
|
|
|
$this->assertSame(Grpc\READ, $event->type); |
|
|
|
$this->assertEquals($req_text, $event->data); |
|
|
|
$this->assertSame($req_text, $event->data); |
|
|
|
|
|
|
|
|
|
|
|
// the server replies |
|
|
|
// the server replies |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->start_write($reply_text, $server_tag); |
|
|
|
$server_call->start_write($reply_text, $server_tag)); |
|
|
|
|
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\WRITE_ACCEPTED, $event->type); |
|
|
|
$this->assertSame(Grpc\WRITE_ACCEPTED, $event->type); |
|
|
|
|
|
|
|
|
|
|
|
// the client reads the metadata |
|
|
|
// the client reads the metadata |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\CLIENT_METADATA_READ, $event->type); |
|
|
|
$this->assertSame(Grpc\CLIENT_METADATA_READ, $event->type); |
|
|
|
|
|
|
|
|
|
|
|
// the client reads the reply |
|
|
|
// the client reads the reply |
|
|
|
$call->start_read($tag); |
|
|
|
$call->start_read($tag); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\READ, $event->type); |
|
|
|
$this->assertSame(Grpc\READ, $event->type); |
|
|
|
$this->assertEquals($reply_text, $event->data); |
|
|
|
$this->assertSame($reply_text, $event->data); |
|
|
|
|
|
|
|
|
|
|
|
// the client sends writes done |
|
|
|
// the client sends writes done |
|
|
|
$call->writes_done($tag); |
|
|
|
$call->writes_done($tag); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertEquals(Grpc\OP_OK, $event->data); |
|
|
|
$this->assertSame(Grpc\OP_OK, $event->data); |
|
|
|
|
|
|
|
|
|
|
|
// the server sends the status |
|
|
|
// the server sends the status |
|
|
|
$this->assertEquals(Grpc\CALL_OK, |
|
|
|
$server_call->start_write_status(GRPC\STATUS_OK, $status_text, $server_tag); |
|
|
|
$server_call->start_write_status(GRPC\STATUS_OK, |
|
|
|
|
|
|
|
$status_text, |
|
|
|
|
|
|
|
$server_tag)); |
|
|
|
|
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertEquals(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISH_ACCEPTED, $event->type); |
|
|
|
$this->assertEquals(Grpc\OP_OK, $event->data); |
|
|
|
$this->assertSame(Grpc\OP_OK, $event->data); |
|
|
|
|
|
|
|
|
|
|
|
// the client gets FINISHED |
|
|
|
// the client gets FINISHED |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$event = $this->client_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\FINISHED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISHED, $event->type); |
|
|
|
$status = $event->data; |
|
|
|
$status = $event->data; |
|
|
|
$this->assertEquals(Grpc\STATUS_OK, $status->code); |
|
|
|
$this->assertSame(Grpc\STATUS_OK, $status->code); |
|
|
|
$this->assertEquals($status_text, $status->details); |
|
|
|
$this->assertSame($status_text, $status->details); |
|
|
|
|
|
|
|
|
|
|
|
// and the server gets FINISHED |
|
|
|
// and the server gets FINISHED |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$event = $this->server_queue->next($deadline); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertNotNull($event); |
|
|
|
$this->assertEquals(Grpc\FINISHED, $event->type); |
|
|
|
$this->assertSame(Grpc\FINISHED, $event->type); |
|
|
|
|
|
|
|
|
|
|
|
unset($call); |
|
|
|
unset($call); |
|
|
|
unset($server_call); |
|
|
|
unset($server_call); |
|
|
|