@@ -573,21 +573,29 @@ public void getSession_wrongUser_returnsEmpty() {
573573
574574 @ Test
575575 public void deleteSession_wrongUser_deniedAndSessionKept () {
576+ sessionMap .put ("victim-session" , mockSessionJson ("victim-session" , "2024-12-12T12:12:12Z" ));
576577 // The ownership error surfaces on subscription, so hoist the Completable out.
577- Completable deletion = vertexAiSessionService .deleteSession ("123" , "attacker" , "1" );
578- assertThrows (SecurityException .class , deletion ::blockingAwait );
578+ Completable deletion =
579+ vertexAiSessionService .deleteSession ("123" , "attacker" , "victim-session" );
580+ SecurityException exception = assertThrows (SecurityException .class , deletion ::blockingAwait );
581+ assertThat (exception ).hasMessageThat ().doesNotContain ("attacker" );
582+ assertThat (exception ).hasMessageThat ().doesNotContain ("victim-session" );
579583 // The session is still readable by its real owner, i.e. it was not deleted.
580584 assertThat (
581- vertexAiSessionService .getSession ("123" , "user" , "1" , Optional .empty ()).blockingGet ())
585+ vertexAiSessionService
586+ .getSession ("123" , "user" , "victim-session" , Optional .empty ())
587+ .blockingGet ())
582588 .isNotNull ();
583589 }
584590
585591 // Session id validation is synchronous, so each call below throws before returning a stream.
586592 @ Test
587593 public void getSession_invalidSessionId_throws () {
588- assertThrows (
589- IllegalArgumentException .class ,
590- () -> vertexAiSessionService .getSession ("123" , "user" , "1/../2" , Optional .empty ()));
594+ IllegalArgumentException exception =
595+ assertThrows (
596+ IllegalArgumentException .class ,
597+ () -> vertexAiSessionService .getSession ("123" , "user" , "1/../2" , Optional .empty ()));
598+ assertThat (exception ).hasMessageThat ().doesNotContain ("1/../2" );
591599 }
592600
593601 @ Test
@@ -612,6 +620,15 @@ public void appendEvent_invalidSessionId_throws() {
612620 IllegalArgumentException .class , () -> vertexAiSessionService .appendEvent (session , event ));
613621 }
614622
623+ @ Test
624+ public void getSession_invalidAppName_throws () {
625+ IllegalArgumentException exception =
626+ assertThrows (
627+ IllegalArgumentException .class ,
628+ () -> vertexAiSessionService .getSession ("customer-app" , "user" , "1" , Optional .empty ()));
629+ assertThat (exception ).hasMessageThat ().doesNotContain ("customer-app" );
630+ }
631+
615632 @ Test
616633 public void listEvents_empty () {
617634 assertThat (vertexAiSessionService .listEvents ("789" , "user1" , "3" ).blockingGet ().events ())
0 commit comments