404 when requesting activiti endpoint

85 Views Asked by At

I'm rather new to activiti. We have a project that was using an older version of activiti and spring boot. We have upgraded but I am seeing issues.

Test code:

    @Value("${activiti.sys_username}")
    private String username;
    @Value("${activiti.password}")
    private String password;

    @Test
    public void givenAuthenticated_whenRejectingLevel1_then() throws Exception {
        mvc.perform(post("/runtime/process-instances")
                .header(HttpHeaders.AUTHORIZATION, Base64.getEncoder().encodeToString(String.format("BASIC %s:%s", username, password).getBytes()))
                .contentType(MediaType.APPLICATION_JSON)
                .content("""
                         {
                            "processDefinitionId" : "isae3402"
                         }
                         """))
                .andExpect(status().isOk());
    }

However in the logs I am receiving a 404:

MockHttpServletRequest:
      HTTP Method = POST
      Request URI = /runtime/process-instances
       Parameters = {}
          Headers = [Content-Type:"application/json;charset=UTF-8", Authorization:"QkFTSUMgYWN0aXZpdGk6SDRja3Rpdml0aSE=", Content-Length:"42"]
             Body = {
   "processDefinitionId" : "isae3402"
}

    Session Attrs = {}

Handler:
             Type = org.springframework.web.servlet.resource.ResourceHttpRequestHandler

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = null

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 404
    Error message = null
          Headers = [Vary:"Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers", X-Content-Type-Options:"nosniff", X-XSS-Protection:"1; mode=block", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY"]
     Content type = null
             Body =
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

I see that in older versions of activiti there is a starter rest artifact but that is not available in the version of activiti I am using.

Is there anything I am missing? I have looked at the sample projects on github but none of them have tests :-/

  • Java 17
  • Spring boot 2.7.10
  • Activiti 7.9

I'm expecting a 200 back when calling the endpoint: /runtime/process-instances

EDIT 1: tried changing the URL as I have seem some examples on the web, but still receiving a 404

2023-04-05 11:16:54.165 DEBUG 19532 --- [           main] org.springframework.test.context.cache   : Spring test ApplicationContext cache statistics: [DefaultContextCache@1fd77205 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 15, missCount = 1]
2023-04-05 11:16:54.193 DEBUG 19532 --- [           main] o.s.security.web.FilterChainProxy        : Securing POST /activiti-rest/service/runtime/process-instances
2023-04-05 11:16:54.202 DEBUG 19532 --- [           main] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to empty SecurityContext
2023-04-05 11:16:54.207 DEBUG 19532 --- [           main] o.s.s.w.a.AnonymousAuthenticationFilter  : Set SecurityContextHolder to anonymous SecurityContext
2023-04-05 11:16:54.224 DEBUG 19532 --- [           main] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorized filter invocation [POST /activiti-rest/service/runtime/process-instances] with attributes [permitAll]
2023-04-05 11:16:54.225 DEBUG 19532 --- [           main] o.s.security.web.FilterChainProxy        : Secured POST /activiti-rest/service/runtime/process-instances
2023-04-05 11:16:54.228 DEBUG 19532 --- [           main] o.s.t.web.servlet.TestDispatcherServlet  : POST "/activiti-rest/service/runtime/process-instances", parameters={}
2023-04-05 11:16:54.243 DEBUG 19532 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
2023-04-05 11:16:54.249 DEBUG 19532 --- [           main] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2023-04-05 11:16:54.253 DEBUG 19532 --- [           main] w.c.HttpSessionSecurityContextRepository : Did not store anonymous SecurityContext
2023-04-05 11:16:54.254 DEBUG 19532 --- [           main] o.s.t.web.servlet.TestDispatcherServlet  : Completed 404 NOT_FOUND
2023-04-05 11:16:54.255 DEBUG 19532 --- [           main] w.c.HttpSessionSecurityContextRepository : Did not store anonymous SecurityContext
2023-04-05 11:16:54.255 DEBUG 19532 --- [           main] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request

Edit 2:

Removing:

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.csrf()
            .disable()
            .authorizeRequests()
                .anyRequest()
                .permitAll();

        return http.build();
    }

From the configuration yields a 403.

Edit 3: Looks like activiti-cloud needs to be included as searching the project I can find the endpoints.

0

There are 0 best solutions below