@@ -933,6 +933,63 @@ public void Alias_PassportFromWithInvalidIdFormat_WarnsAndDropsCall()
933933 }
934934 }
935935
936+ [ Test ]
937+ public void Alias_IdenticalIds_WarnsAndDropsCall ( )
938+ {
939+ var lines = new List < string > ( ) ;
940+ Log . Writer = lines . Add ;
941+ try
942+ {
943+ ImmutableAudience . Init ( MakeConfig ( ConsentLevel . Full ) ) ;
944+
945+ ImmutableAudience . Alias ( "same_id" , IdentityType . Steam , "same_id" , IdentityType . Steam ) ;
946+ ImmutableAudience . Shutdown ( ) ;
947+
948+ Assert . That ( lines , Has . Some . Contains ( "identical fromId and toId" ) ,
949+ "identical ids should surface a warning" ) ;
950+
951+ var queueDir = AudiencePaths . QueueDir ( _testDir ) ;
952+ var contents = Directory . GetFiles ( queueDir , "*.json" )
953+ . Select ( File . ReadAllText ) . ToList ( ) ;
954+ Assert . IsFalse ( contents . Any ( c => c . Contains ( "\" alias\" " ) ) ,
955+ "the event should be dropped, not just flagged" ) ;
956+ }
957+ finally
958+ {
959+ Log . Writer = null ;
960+ }
961+ }
962+
963+ [ Test ]
964+ public void Alias_IdenticalIdsDifferentTypes_StillWarnsAndDropsCall ( )
965+ {
966+ // Matches the backend: it rejects on id equality alone, ignoring
967+ // identityType, so the client must reject this case too instead
968+ // of sending something the backend will bounce.
969+ var lines = new List < string > ( ) ;
970+ Log . Writer = lines . Add ;
971+ try
972+ {
973+ ImmutableAudience . Init ( MakeConfig ( ConsentLevel . Full ) ) ;
974+
975+ ImmutableAudience . Alias ( "same_id" , IdentityType . Steam , "same_id" , IdentityType . Email ) ;
976+ ImmutableAudience . Shutdown ( ) ;
977+
978+ Assert . That ( lines , Has . Some . Contains ( "identical fromId and toId" ) ,
979+ "identical ids should surface a warning even with different identityTypes" ) ;
980+
981+ var queueDir = AudiencePaths . QueueDir ( _testDir ) ;
982+ var contents = Directory . GetFiles ( queueDir , "*.json" )
983+ . Select ( File . ReadAllText ) . ToList ( ) ;
984+ Assert . IsFalse ( contents . Any ( c => c . Contains ( "\" alias\" " ) ) ,
985+ "the event should be dropped, not just flagged" ) ;
986+ }
987+ finally
988+ {
989+ Log . Writer = null ;
990+ }
991+ }
992+
936993 [ Test ]
937994 public void Alias_NonPassportIdentityTypes_DoesNotWarn ( )
938995 {
0 commit comments