tests/test-http-api-httpv2.t
changeset 37051 40206e227412
parent 37050 37d7a1d18b97
child 37052 8c3c47362934
equal deleted inserted replaced
37050:37d7a1d18b97 37051:40206e227412
     1   $ HTTPV2=exp-http-v2-0001
     1   $ HTTPV2=exp-http-v2-0001
     2   $ MEDIATYPE=application/mercurial-tbd
     2   $ MEDIATYPE=application/mercurial-exp-framing-0001
     3 
     3 
     4   $ send() {
     4   $ send() {
     5   >   hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT/
     5   >   hg --verbose debugwireproto --peer raw http://$LOCALIP:$HGPORT/
     6   > }
     6   > }
     7 
     7 
   118   s> makefile('rb', None)
   118   s> makefile('rb', None)
   119   s>     HTTP/1.1 406 Not Acceptable\r\n
   119   s>     HTTP/1.1 406 Not Acceptable\r\n
   120   s>     Server: testing stub value\r\n
   120   s>     Server: testing stub value\r\n
   121   s>     Date: $HTTP_DATE$\r\n
   121   s>     Date: $HTTP_DATE$\r\n
   122   s>     Content-Type: text/plain\r\n
   122   s>     Content-Type: text/plain\r\n
   123   s>     Content-Length: 72\r\n
   123   s>     Content-Length: 85\r\n
   124   s>     \r\n
   124   s>     \r\n
   125   s>     client MUST specify Accept header with value: application/mercurial-tbd\n
   125   s>     client MUST specify Accept header with value: application/mercurial-exp-framing-0001\n
   126 
   126 
   127 Bad Accept header results in 406
   127 Bad Accept header results in 406
   128 
   128 
   129   $ send << EOF
   129   $ send << EOF
   130   > httprequest POST api/$HTTPV2/ro/customreadonly
   130   > httprequest POST api/$HTTPV2/ro/customreadonly
   141   s> makefile('rb', None)
   141   s> makefile('rb', None)
   142   s>     HTTP/1.1 406 Not Acceptable\r\n
   142   s>     HTTP/1.1 406 Not Acceptable\r\n
   143   s>     Server: testing stub value\r\n
   143   s>     Server: testing stub value\r\n
   144   s>     Date: $HTTP_DATE$\r\n
   144   s>     Date: $HTTP_DATE$\r\n
   145   s>     Content-Type: text/plain\r\n
   145   s>     Content-Type: text/plain\r\n
   146   s>     Content-Length: 72\r\n
   146   s>     Content-Length: 85\r\n
   147   s>     \r\n
   147   s>     \r\n
   148   s>     client MUST specify Accept header with value: application/mercurial-tbd\n
   148   s>     client MUST specify Accept header with value: application/mercurial-exp-framing-0001\n
   149 
   149 
   150 Bad Content-Type header results in 415
   150 Bad Content-Type header results in 415
   151 
   151 
   152   $ send << EOF
   152   $ send << EOF
   153   > httprequest POST api/$HTTPV2/ro/customreadonly
   153   > httprequest POST api/$HTTPV2/ro/customreadonly
   156   >     content-type: badmedia
   156   >     content-type: badmedia
   157   > EOF
   157   > EOF
   158   using raw connection to peer
   158   using raw connection to peer
   159   s>     POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n
   159   s>     POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n
   160   s>     Accept-Encoding: identity\r\n
   160   s>     Accept-Encoding: identity\r\n
   161   s>     accept: application/mercurial-tbd\r\n
   161   s>     accept: application/mercurial-exp-framing-0001\r\n
   162   s>     content-type: badmedia\r\n
   162   s>     content-type: badmedia\r\n
   163   s>     user-agent: test\r\n
   163   s>     user-agent: test\r\n
   164   s>     host: $LOCALIP:$HGPORT\r\n (glob)
   164   s>     host: $LOCALIP:$HGPORT\r\n (glob)
   165   s>     \r\n
   165   s>     \r\n
   166   s> makefile('rb', None)
   166   s> makefile('rb', None)
   167   s>     HTTP/1.1 415 Unsupported Media Type\r\n
   167   s>     HTTP/1.1 415 Unsupported Media Type\r\n
   168   s>     Server: testing stub value\r\n
   168   s>     Server: testing stub value\r\n
   169   s>     Date: $HTTP_DATE$\r\n
   169   s>     Date: $HTTP_DATE$\r\n
   170   s>     Content-Type: text/plain\r\n
   170   s>     Content-Type: text/plain\r\n
   171   s>     Content-Length: 75\r\n
   171   s>     Content-Length: 88\r\n
   172   s>     \r\n
   172   s>     \r\n
   173   s>     client MUST send Content-Type header with value: application/mercurial-tbd\n
   173   s>     client MUST send Content-Type header with value: application/mercurial-exp-framing-0001\n
   174 
   174 
   175 Request to read-only command works out of the box
   175 Request to read-only command works out of the box
   176 
   176 
   177   $ send << EOF
   177   $ send << EOF
   178   > httprequest POST api/$HTTPV2/ro/customreadonly
   178   > httprequest POST api/$HTTPV2/ro/customreadonly
   179   >     accept: $MEDIATYPE
   179   >     accept: $MEDIATYPE
   180   >     content-type: $MEDIATYPE
   180   >     content-type: $MEDIATYPE
   181   >     user-agent: test
   181   >     user-agent: test
       
   182   >     frame command-name eos customreadonly
   182   > EOF
   183   > EOF
   183   using raw connection to peer
   184   using raw connection to peer
   184   s>     POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n
   185   s>     POST /api/exp-http-v2-0001/ro/customreadonly HTTP/1.1\r\n
   185   s>     Accept-Encoding: identity\r\n
   186   s>     Accept-Encoding: identity\r\n
   186   s>     accept: application/mercurial-tbd\r\n
   187   s>     accept: application/mercurial-exp-framing-0001\r\n
   187   s>     content-type: application/mercurial-tbd\r\n
   188   s>     content-type: application/mercurial-exp-framing-0001\r\n
   188   s>     user-agent: test\r\n
   189   s>     user-agent: test\r\n
   189   s>     host: $LOCALIP:$HGPORT\r\n (glob)
   190   s>     content-length: 18\r\n
   190   s>     \r\n
   191   s>     host: $LOCALIP:$HGPORT\r\n (glob)
       
   192   s>     \r\n
       
   193   s>     \x0e\x00\x00\x11customreadonly
   191   s> makefile('rb', None)
   194   s> makefile('rb', None)
   192   s>     HTTP/1.1 200 OK\r\n
   195   s>     HTTP/1.1 200 OK\r\n
   193   s>     Server: testing stub value\r\n
   196   s>     Server: testing stub value\r\n
   194   s>     Date: $HTTP_DATE$\r\n
   197   s>     Date: $HTTP_DATE$\r\n
   195   s>     Content-Type: text/plain\r\n
   198   s>     Content-Type: text/plain\r\n
   281   $ send << EOF
   284   $ send << EOF
   282   > httprequest POST api/$HTTPV2/rw/customreadonly
   285   > httprequest POST api/$HTTPV2/rw/customreadonly
   283   >     user-agent: test
   286   >     user-agent: test
   284   >     accept: $MEDIATYPE
   287   >     accept: $MEDIATYPE
   285   >     content-type: $MEDIATYPE
   288   >     content-type: $MEDIATYPE
       
   289   >     frame command-name eos customreadonly
   286   > EOF
   290   > EOF
   287   using raw connection to peer
   291   using raw connection to peer
   288   s>     POST /api/exp-http-v2-0001/rw/customreadonly HTTP/1.1\r\n
   292   s>     POST /api/exp-http-v2-0001/rw/customreadonly HTTP/1.1\r\n
   289   s>     Accept-Encoding: identity\r\n
   293   s>     Accept-Encoding: identity\r\n
   290   s>     accept: application/mercurial-tbd\r\n
   294   s>     accept: application/mercurial-exp-framing-0001\r\n
   291   s>     content-type: application/mercurial-tbd\r\n
   295   s>     content-type: application/mercurial-exp-framing-0001\r\n
   292   s>     user-agent: test\r\n
   296   s>     user-agent: test\r\n
   293   s>     host: $LOCALIP:$HGPORT\r\n (glob)
   297   s>     content-length: 18\r\n
   294   s>     \r\n
   298   s>     host: $LOCALIP:$HGPORT\r\n (glob)
       
   299   s>     \r\n
       
   300   s>     \x0e\x00\x00\x11customreadonly
   295   s> makefile('rb', None)
   301   s> makefile('rb', None)
   296   s>     HTTP/1.1 200 OK\r\n
   302   s>     HTTP/1.1 200 OK\r\n
   297   s>     Server: testing stub value\r\n
   303   s>     Server: testing stub value\r\n
   298   s>     Date: $HTTP_DATE$\r\n
   304   s>     Date: $HTTP_DATE$\r\n
   299   s>     Content-Type: text/plain\r\n
   305   s>     Content-Type: text/plain\r\n
   309   >     accept: $MEDIATYPE
   315   >     accept: $MEDIATYPE
   310   > EOF
   316   > EOF
   311   using raw connection to peer
   317   using raw connection to peer
   312   s>     POST /api/exp-http-v2-0001/rw/badcommand HTTP/1.1\r\n
   318   s>     POST /api/exp-http-v2-0001/rw/badcommand HTTP/1.1\r\n
   313   s>     Accept-Encoding: identity\r\n
   319   s>     Accept-Encoding: identity\r\n
   314   s>     accept: application/mercurial-tbd\r\n
   320   s>     accept: application/mercurial-exp-framing-0001\r\n
   315   s>     user-agent: test\r\n
   321   s>     user-agent: test\r\n
   316   s>     host: $LOCALIP:$HGPORT\r\n (glob)
   322   s>     host: $LOCALIP:$HGPORT\r\n (glob)
   317   s>     \r\n
   323   s>     \r\n
   318   s> makefile('rb', None)
   324   s> makefile('rb', None)
   319   s>     HTTP/1.1 404 Not Found\r\n
   325   s>     HTTP/1.1 404 Not Found\r\n