Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client and Plan support #36

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

msavy
Copy link
Member

@msavy msavy commented Apr 7, 2018

Reworked jquantins work, but excluded the deepList stuff which needs some additional discussion.

@msavy
Copy link
Member Author

msavy commented Apr 7, 2018

@outofcoffee Any idea which branch I should work against?

Also just noticed a few bits I need to zap before merging, but please have a play and see if it works for you.

@msavy
Copy link
Member Author

msavy commented Apr 7, 2018

Declarative bits that are missing will be committed shortly

@msavy
Copy link
Member Author

msavy commented Apr 7, 2018

Now I can see that the CLI needs a couple of extra commands adding to enable plans to be added to APIs (i.e. non declarative)

@msavy
Copy link
Member Author

msavy commented Apr 8, 2018

@pcornish what is your philosophy when it comes to error handling? For example, at the moment with certain list commands you just get an ugly exception.

My thoughts are that we could parse the returned JSON and display the canonical message? What do you think.

Or is this already meant to happen?

e.g.

./apiman manager client contract create -o foo -n myclient -v 1.0 -an myapi -av 1 -pn fooplanj
ERROR HTTP 404 Not Found but expected 200:
{"type":"PlanNotFoundException","errorCode":6002,"message":"Plan does not exist: fooplanj","moreInfoUrl":null,"stacktrace":"io.apiman.manager.api.rest.contract.exceptions.PlanNotFoundException: Plan does not exist: fooplanj\n\tat io.apiman.manager.api.rest.impl.util.ExceptionFactory.planNotFoundException(ExceptionFactory.java:302)\n\tat io.apiman.manager.api.rest.impl.OrganizationResourceImpl.createContractInternal(OrganizationResourceImpl.java:1004)\n\tat io.apiman.manager.api.rest.impl.OrganizationResourceImpl.createContract(OrganizationResourceImpl.java:945)\n\tat io.apiman.manager.api.rest.impl.OrganizationResourceImpl$Proxy$_$$_WeldClientProxy.createContract(Unknown Source)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)\n\tat org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)\n\tat org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)\n\tat org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)\n\tat org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)\n\tat org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)\n\tat org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)\n\tat io.apiman.common.servlet.RootResourceFilter.doFilter(RootResourceFilter.java:59)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apiman.manager.api.war.TransactionWatchdogFilter.doFilter(TransactionWatchdogFilter.java:57)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apiman.manager.api.security.impl.DefaultSecurityContextFilter.doFilter(DefaultSecurityContextFilter.java:56)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apiman.common.servlet.DisableCachingFilter.doFilter(DisableCachingFilter.java:52)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apiman.common.servlet.ApimanCorsFilter.doFilter(ApimanCorsFilter.java:71)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.apiman.common.servlet.LocaleFilter.doFilter(LocaleFilter.java:61)\n\tat io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)\n\tat io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)\n\tat io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)\n\tat io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)\n\tat io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)\n\tat org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat org.keycloak.adapters.undertow.UndertowAuthenticatedActionsHandler.handleRequest(UndertowAuthenticatedActionsHandler.java:66)\n\tat io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)\n\tat io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)\n\tat io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)\n\tat io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)\n\tat io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)\n\tat io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)\n\tat io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)\n\tat io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)\n\tat io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)\n\tat io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat org.keycloak.adapters.undertow.ServletPreAuthActionsHandler.handleRequest(ServletPreAuthActionsHandler.java:69)\n\tat io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)\n\tat io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)\n\tat io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)\n\tat io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)\n\tat io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)\n\tat io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)\n\tat io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)\n\tat io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)\n\tat io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"}

vs (mocked up example) -- something better than a huge trace.

./apiman manager client contract create -o foo -n myclient -v 1.0 -an myapi -av 1 -pn fooplanj
ERROR HTTP 404 Not Found but expected 200:
PlanNotFoundException 
ErrorCode: 6002
Message: Plan does not exist: fooplanj

I'm still not quite clear whether this is meant to be happening but it's b0rked or we should be relying on CLI-side validation (which seems a lot of work and maintenance in this circumstance).

msavy added 2 commits April 9, 2018 14:39
Behaviour seemed to have changed for some reason, so took opportunity to align
dependencies with Apiman main project use the ser/deser feature to fix.

Signed-off-by: Marc Savy <[email protected]>
Signed-off-by: Marc Savy <[email protected]>
@msavy
Copy link
Member Author

msavy commented Apr 11, 2018

Okay, was having an issue that turns out to be related to a bug in Maven 3.5.0's snapshot metadata.

Will be pushing some more changes shortly, hopefully.

@msavy
Copy link
Member Author

msavy commented Apr 11, 2018

@pcornish I think your recent "exception cause" changes on apiman/apiman may have had an unintended side-effect of breaking the apiman-cli tests -- as some exceptions that were 404 are now showing as 500s.

Investigating!

@msavy
Copy link
Member Author

msavy commented Apr 11, 2018

Reference for the above d9f95c2990f01197152c5d5f3ed855aca1ea5bc9

@outofcoffee
Copy link
Collaborator

outofcoffee commented May 26, 2018

Hi @msavy. On latest master (e35c0f0) and develop (776a17e) the tests look OK. Here are the steps I ran (straight from the travis config file):

$ docker run -d -p 8080:8080 apiman/on-wildfly10:master
$ ./gradlew test -PintegrationTest --info --stacktrace
...
BUILD SUCCESSFUL in 35s
5 actionable tasks: 3 executed, 2 up-to-date

If you have some specific tests you want me to look at let me know and I'll happily take a look.

@msavy
Copy link
Member Author

msavy commented May 26, 2018

@pcornish I reverted a PR on apiman/apiman itself as it was causing the unintended side-effects.

@outofcoffee
Copy link
Collaborator

Ah yes, sorry, I did see that :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants