@@ -36,7 +36,7 @@ pub fn ingest_app<V: TokenValidator>(state: AppState<V>) -> Router {
3636 "/kubelet_stats_summary" ,
3737 post ( ingest:: kubelet_stats_summary) ,
3838 )
39- . route ( "/linux_agent /{node_name}" , post ( ingest:: linux_agent ) )
39+ . route ( "/system_agent /{node_name}" , post ( ingest:: system_agent ) )
4040 . route_layer ( middleware:: from_fn_with_state (
4141 state. clone ( ) ,
4242 auth:: kubernetes:: authenticate,
@@ -50,68 +50,26 @@ pub fn ingest_app<V: TokenValidator>(state: AppState<V>) -> Router {
5050
5151#[ cfg( test) ]
5252mod tests {
53- use axum:: body:: { Body , Bytes } ;
53+ use axum:: body:: Body ;
5454 use axum:: http:: { Request , StatusCode } ;
55- use k8s_openapi:: api:: authentication:: v1:: { TokenReview , TokenReviewStatus , UserInfo } ;
5655 use tower:: ServiceExt ;
5756
5857 use super :: * ;
59- use crate :: state:: tests:: { MockValidator , test_app_state, test_app_state_with_validator} ;
60-
61- fn authenticated_review ( username : & str ) -> TokenReview {
62- TokenReview {
63- status : Some ( TokenReviewStatus {
64- authenticated : Some ( true ) ,
65- user : Some ( UserInfo {
66- username : Some ( username. to_string ( ) ) ,
67- ..Default :: default ( )
68- } ) ,
69- ..Default :: default ( )
70- } ) ,
71- ..Default :: default ( )
72- }
73- }
74-
75- #[ tokio:: test]
76- async fn linux_agent_ingest_populates_cache_and_returns_ok ( ) {
77- let state = test_app_state_with_validator ( MockValidator {
78- response : Ok ( authenticated_review (
79- "system:serviceaccount:test-ns:test-writer" ,
80- ) ) ,
81- } ) ;
82- let cache = state. linux_agent_cache . clone ( ) ;
83- let app = ingest_app ( state) ;
84-
85- let resp = app
86- . oneshot (
87- Request :: builder ( )
88- . method ( "POST" )
89- . uri ( "/ingest/linux_agent/node-1" )
90- . header ( "Authorization" , "Bearer test-token" )
91- . body ( Body :: from ( "<<<check_mk>>>\n Version: 2.5.0\n " ) )
92- . unwrap ( ) ,
93- )
94- . await
95- . unwrap ( ) ;
96-
97- assert_eq ! ( resp. status( ) , StatusCode :: OK ) ;
98- cache. run_pending_tasks ( ) . await ;
99- assert_eq ! (
100- cache. get( "node-1" ) . await . map( |v| v. payload. clone( ) ) ,
101- Some ( Bytes :: from_static( b"<<<check_mk>>>\n Version: 2.5.0\n " ) )
102- ) ;
103- }
58+ use crate :: state:: tests:: test_app_state;
10459
60+ /// Sanity check that the ingest route is actually wired up behind the
61+ /// kubernetes-token middleware; handler-level behavior is covered in
62+ /// `handlers::ingest::tests`.
10563 #[ tokio:: test]
106- async fn linux_agent_ingest_requires_auth ( ) {
64+ async fn system_agent_ingest_requires_auth ( ) {
10765 let state = test_app_state ( ) ;
10866 let app = ingest_app ( state) ;
10967
11068 let resp = app
11169 . oneshot (
11270 Request :: builder ( )
11371 . method ( "POST" )
114- . uri ( "/ingest/linux_agent /node-1" )
72+ . uri ( "/ingest/system_agent /node-1" )
11573 . body ( Body :: from ( "<<<check_mk>>>\n " ) )
11674 . unwrap ( ) ,
11775 )
0 commit comments