File tree Expand file tree Collapse file tree
src/main/java/io/github/devopsws/demo/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ tasks :
2+ - init : make init-env
3+
14vscode :
25 extensions :
36 - linuxsuren.api-testing
Original file line number Diff line number Diff line change @@ -4,3 +4,11 @@ test-e2e:
44 cd e2e && ./start.sh
55run-demo :
66 cd e2e && docker compose up server
7+
8+ local-test :
9+ atest run -p e2e/test-suite.yaml
10+
11+ init-env :
12+ curl https://linuxsuren.github.io/tools/install.sh| bash
13+ hd i cli/cli
14+ hd i atest
Original file line number Diff line number Diff line change @@ -10,17 +10,23 @@ items:
1010- name : toLowerWithoutParam
1111 request :
1212 api : /lower
13+ header :
14+ Authorization : Basic YWRtaW46MTIzNDU2
1315 expect :
1416 statusCode : 400
1517- name : toLower
1618 request :
1719 api : /lower?text=Hello
20+ header :
21+ Authorization : Basic YWRtaW46MTIzNDU2
1822 expect :
1923 body : hello
2024
2125# # Cookies
2226- name : no-cookie
2327 request :
2428 api : /cookies/echo
29+ header :
30+ Authorization : Basic YWRtaW46MTIzNDU2
2531 expect :
26- body : cookies are empty
32+ body : cookies are empty
Original file line number Diff line number Diff line change 2323 </dependency >
2424
2525 <dependency >
26- <groupId >org.springdoc</groupId >
27- <artifactId >springdoc-openapi-starter-webmvc-ui</artifactId >
28- <version >2.2.0</version >
26+ <groupId >org.springframework.boot</groupId >
27+ <artifactId >spring-boot-starter-security</artifactId >
28+ </dependency >
29+
30+ <dependency >
31+ <groupId >org.springdoc</groupId >
32+ <artifactId >springdoc-openapi-starter-webmvc-ui</artifactId >
33+ <version >2.2.0</version >
2934 </dependency >
3035
3136 <dependency >
Original file line number Diff line number Diff line change 1+ package io .github .devopsws .demo .config ;
2+
3+ import org .springframework .context .annotation .Bean ;
4+ import org .springframework .context .annotation .Configuration ;
5+ import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
6+ import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
7+ import org .springframework .security .core .userdetails .User ;
8+ import org .springframework .security .core .userdetails .UserDetails ;
9+ import org .springframework .security .core .userdetails .UserDetailsService ;
10+ import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
11+ import org .springframework .security .web .SecurityFilterChain ;
12+
13+ @ Configuration
14+ @ EnableWebSecurity
15+ public class WebSecurityConfig {
16+
17+ @ Bean
18+ public SecurityFilterChain securityFilterChain (HttpSecurity http ) throws Exception {
19+ http .authorizeHttpRequests ((requests ) -> requests
20+ .requestMatchers ("/health" , "/v3/api-docs" ).permitAll ()
21+ .anyRequest ().authenticated ()).httpBasic ();
22+
23+ return http .build ();
24+ }
25+
26+ @ Bean
27+ public UserDetailsService userDetailsService () {
28+ UserDetails user = User .withDefaultPasswordEncoder ()
29+ .username ("admin" )
30+ .password ("123456" )
31+ .roles ("USER" )
32+ .build ();
33+
34+ return new InMemoryUserDetailsManager (user );
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments