Skip to content

Instantly share code, notes, and snippets.

@EricWittmann
Created January 27, 2016 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricWittmann/90c454433954b0cea867 to your computer and use it in GitHub Desktop.
Save EricWittmann/90c454433954b0cea867 to your computer and use it in GitHub Desktop.
ewittman@CONDOR ~/apiman-1.1.9.Final
$ ./do-test.sh
#
# Set up a new API in apiman
#
+ curl --header 'Content-Type: application/json' --header 'Authorization: BASIC YWRtaW46YWRtaW4xMjMh' -XPOST http://localhost:8080/apiman/organizations -d '{"name":"Test"}'
{"id":"Test","name":"Test","description":null,"createdBy":"admin","createdOn":1453915336172,"modifiedBy":"admin","modifiedOn":1453915336172}+ curl --header 'Content-Type: applicati
on/json' --header 'Authorization: BASIC YWRtaW46YWRtaW4xMjMh' -XPOST http://localhost:8080/apiman/organizations/Test/services -d '
{
"name" : "test-api",
"description" : "Just a test API.",
"initialVersion" : "1.0"
}'
{"organization":{"id":"Test","name":"Test","description":null,"createdBy":"admin","createdOn":1453915336172,"modifiedBy":"admin","modifiedOn":1453915336172},"id":"test-api","name":
"test-api","description":"Just a test API.","createdBy":"admin","createdOn":1453915338399}+ curl --header 'Content-Type: application/json' --header 'Authorization: BASIC YWRtaW46YW
RtaW4xMjMh' -XPUT http://localhost:8080/apiman/organizations/Test/services/test-api/versions/1.0 -d '
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/echo",
"endpointType" : "rest",
"publicService" : true
}'
{"id":4,"service":{"organization":{"id":"Test","name":"Test","description":null,"createdBy":"admin","createdOn":1453915336172,"modifiedBy":"admin","modifiedOn":1453915336172},"id":
"test-api","name":"test-api","description":"Just a test API.","createdBy":"admin","createdOn":1453915338399},"status":"Ready","endpoint":"http://seprohub-ibek.rhcloud.com:80/rest/e
cho","endpointType":"rest","endpointProperties":{},"gateways":[{"gatewayId":"TheGateway"}],"publicService":true,"plans":[],"version":"1.0","createdBy":"admin","createdOn":145391533
8423,"modifiedBy":"admin","modifiedOn":1453915340556,"publishedOn":null,"retiredOn":null,"definitionType":null}+ curl --header 'Content-Type: application/json' --header 'Authorizat
ion: BASIC YWRtaW46YWRtaW4xMjMh' -XPOST http://localhost:8080/apiman/actions -d '
{
"type" : "publishService",
"organizationId" : "Test",
"entityId" : "test-api",
"entityVersion" : "1.0"
}'
+ set +x
#
# Checking elasticsearch for appropriate data
#
+ curl -XGET http://localhost:19200/apiman_gateway/service/Test:test-api:1.0/_source
{"endpoint":"http://seprohub-ibek.rhcloud.com:80/rest/echo","endpointType":"rest","publicService":true,"organizationId":"Test","serviceId":"test-api","version":"1.0","endpointPrope
rties":[],"policies":[]}+ curl -XGET 'http://localhost:19200/apiman_gateway/service/_search?pretty=true'
{
"took" : 26,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "apiman_gateway",
"_type" : "service",
"_id" : "Test:test-api:1.0",
"_score" : 1.0,
"_source":{"endpoint":"http://seprohub-ibek.rhcloud.com:80/rest/echo","endpointType":"rest","publicService":true,"organizationId":"Test","serviceId":"test-api","version":"1.0
","endpointProperties":[],"policies":[]}
} ]
}
}
+ set +x
#
# Hitting the service via the apiman gateway
#
+ curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/ping
pong+ set +x
#
# Directly modifying elasticsearch data
#
+ curl --header 'Content-Type: application/json' -XPUT http://localhost:19200/apiman_gateway/service/Test:test-api:1.0 -d '
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/status",
"endpointType" : "rest",
"publicService" : true,
"organizationId" : "Example",
"serviceId": "MyService",
"version" : "1.0",
"endpointProperties": [],
"policies":[]
}'
{"_index":"apiman_gateway","_type":"service","_id":"Test:test-api:1.0","_version":2,"created":false}+ set +x
#
# Checking elasticsearch for NEW data
#
+ curl -XGET http://localhost:19200/apiman_gateway/service/Test:test-api:1.0/_source
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/status",
"endpointType" : "rest",
"publicService" : true,
"organizationId" : "Example",
"serviceId": "MyService",
"version" : "1.0",
"endpointProperties": [],
"policies":[]
}+ curl -XGET 'http://localhost:19200/apiman_gateway/service/_search?pretty=true'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "apiman_gateway",
"_type" : "service",
"_id" : "Test:test-api:1.0",
"_score" : 1.0,
"_source":
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/status",
"endpointType" : "rest",
"publicService" : true,
"organizationId" : "Example",
"serviceId": "MyService",
"version" : "1.0",
"endpointProperties": [],
"policies":[]
}
} ]
}
}
+ set +x
#
# Hitting the service via the apiman gateway again (should still hit the old endpoint because we haven't restarted apiman yet
#
+ curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/ping
pong+ echo ''
+ echo ''
+ echo 'Now go ahead and restart apiman and try the service again - it should be using a different endpoint now!'
Now go ahead and restart apiman and try the service again - it should be using a different endpoint now!
ewittman@CONDOR ~/apiman-1.1.9.Final
$ curl -XGET http://localhost:19200/apiman_gateway/service/_search?pretty=true
{
"took" : 44,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "apiman_gateway",
"_type" : "service",
"_id" : "Test:test-api:1.0",
"_score" : 1.0,
"_source":
{
"endpoint" : "http://seprohub-ibek.rhcloud.com:80/rest/status",
"endpointType" : "rest",
"publicService" : true,
"organizationId" : "Example",
"serviceId": "MyService",
"version" : "1.0",
"endpointProperties": [],
"policies":[]
}
} ]
}
}
ewittman@CONDOR ~/apiman-1.1.9.Final
$ curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/ping
<html><head><title>JBoss Web/7.0.13.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-fa
mily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BOD
Y {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Aria
l,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - Failed proces
sing arguments of public javax.ws.rs.core.Response org.jboss.sepro.service.rest.HttpStatus.getStatus(int)</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>m
essage</b> <u>Failed processing arguments of public javax.ws.rs.core.Response org.jboss.sepro.service.rest.HttpStatus.getStatus(int)</u></p><p><b>description</b> <u>The request sen
t by the client was syntactically incorrect (Failed processing arguments of public javax.ws.rs.core.Response org.jboss.sepro.service.rest.HttpStatus.getStatus(int)).</u></p><HR siz
e="1" noshade="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>
ewittman@CONDOR ~/apiman-1.1.9.Final
$ curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/401
<html><head><title>JBoss Web/7.0.13.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-fa
mily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BOD
Y {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Aria
l,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size
="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" nosha
de="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>
ewittman@CONDOR ~/apiman-1.1.9.Final
$ curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/302
ewittman@CONDOR ~/apiman-1.1.9.Final
$ curl -XGET http://localhost:8080/apiman-gateway/Test/test-api/1.0/404
<html><head><title>JBoss Web/7.0.13.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-fa
mily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BOD
Y {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Aria
l,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size
="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade
="noshade"><h3>JBoss Web/7.0.13.Final</h3></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment