@@ -4,10 +4,9 @@ use super::*;
44
55#[ test]
66fn display_connect ( ) {
7- assert ! (
8- AuthCalloutError :: Connect ( "refused" . into( ) )
9- . to_string( )
10- . contains( "NATS connect failed" )
7+ assert_eq ! (
8+ AuthCalloutError :: Connect ( "refused" . into( ) ) . to_string( ) ,
9+ "NATS connect failed: refused"
1110 ) ;
1211}
1312
@@ -17,14 +16,14 @@ fn display_subscribe() {
1716 let e = AuthCalloutError :: Subscribe ( async_nats:: SubscribeError :: new (
1817 async_nats:: SubscribeErrorKind :: InvalidSubject ,
1918 ) ) ;
20- assert ! ( e. to_string( ) . contains ( " auth callout subject" ) ) ;
19+ assert_eq ! ( e. to_string( ) , "subscribe to auth callout subject failed" ) ;
2120 assert ! ( Error :: source( & e) . is_some( ) ) ;
2221}
2322
2423#[ test]
2524fn display_credential_verification ( ) {
2625 let e = AuthCalloutError :: CredentialVerification ( CredentialError :: InvalidCredentials ( "bad token" . into ( ) ) ) ;
27- assert ! ( e. to_string( ) . contains ( "credential verification" ) ) ;
26+ assert_eq ! ( e. to_string( ) , "credential verification failed: bad token" ) ;
2827 assert ! ( std:: error:: Error :: source( & e) . is_some( ) ) ;
2928}
3029
@@ -37,20 +36,17 @@ fn display_jwt_variant() {
3736
3837#[ test]
3938fn display_missing_env_var_unknown_source_and_vault ( ) {
40- assert ! (
41- AuthCalloutError :: MissingEnvVar ( "X" )
42- . to_string( )
43- . contains( "X is not set" )
39+ assert_eq ! (
40+ AuthCalloutError :: MissingEnvVar ( "X" ) . to_string( ) ,
41+ "required environment variable X is not set"
4442 ) ;
45- assert ! (
46- AuthCalloutError :: UnknownSigningKeySource ( "foo" . into( ) )
47- . to_string( )
48- . contains( "foo" )
43+ assert_eq ! (
44+ AuthCalloutError :: UnknownSigningKeySource ( "foo" . into( ) ) . to_string( ) ,
45+ "unknown AUTH_CALLOUT_SIGNING_KEY_SOURCE: foo (expected env, file, or vault)"
4946 ) ;
50- assert ! (
51- AuthCalloutError :: VaultNotConfigured
52- . to_string( )
53- . contains( "not wired yet" )
47+ assert_eq ! (
48+ AuthCalloutError :: VaultNotConfigured . to_string( ) ,
49+ "AUTH_CALLOUT_SIGNING_KEY_SOURCE=vault is not wired yet"
5450 ) ;
5551}
5652
@@ -60,12 +56,12 @@ fn display_and_source_for_key_load_variants() {
6056 path : std:: path:: PathBuf :: from ( "/tmp/x" ) ,
6157 source : std:: io:: Error :: new ( std:: io:: ErrorKind :: NotFound , "nope" ) ,
6258 } ;
63- assert ! ( io. to_string( ) . contains ( " /tmp/x") ) ;
59+ assert_eq ! ( io. to_string( ) , "failed to read signing key at /tmp/x") ;
6460 assert ! ( Error :: source( & io) . is_some( ) ) ;
6561
6662 let bad: Vec < u8 > = vec ! [ 0xff , 0xfe ] ;
6763 let utf8 = AuthCalloutError :: KeyLoadUtf8 ( std:: str:: from_utf8 ( & bad) . unwrap_err ( ) ) ;
68- assert ! ( utf8. to_string( ) . contains ( " UTF-8" ) ) ;
64+ assert_eq ! ( utf8. to_string( ) , "signing key file must be UTF-8 NKey seed" ) ;
6965 assert ! ( Error :: source( & utf8) . is_some( ) ) ;
7066}
7167
@@ -83,25 +79,22 @@ fn source_for_connect_is_none() {
8379#[ test]
8480fn display_covers_remaining_variants ( ) {
8581 let de = serde_json:: from_str :: < String > ( "x" ) . unwrap_err ( ) ;
86- assert ! (
87- AuthCalloutError :: Deserialize ( de)
88- . to_string( )
89- . contains( "deserialize auth callout request" )
82+ assert_eq ! (
83+ AuthCalloutError :: Deserialize ( de) . to_string( ) ,
84+ "failed to deserialize auth callout request"
9085 ) ;
9186 let se = serde_json:: from_str :: < serde_json:: Value > ( "not json" ) . unwrap_err ( ) ;
92- assert ! (
93- AuthCalloutError :: Serialize ( se)
94- . to_string( )
95- . contains( "serialize auth callout response" )
87+ assert_eq ! (
88+ AuthCalloutError :: Serialize ( se) . to_string( ) ,
89+ "failed to serialize auth callout response"
9690 ) ;
9791 let reply_err = AuthCalloutError :: Reply ( async_nats:: PublishError :: new (
9892 async_nats:: client:: PublishErrorKind :: InvalidSubject ,
9993 ) ) ;
100- assert ! ( reply_err. to_string( ) . contains( "publish auth callout reply" ) ) ;
101- assert ! (
102- AuthCalloutError :: WireFormat ( "x" . into( ) )
103- . to_string( )
104- . contains( "wire format" )
94+ assert_eq ! ( reply_err. to_string( ) , "failed to publish auth callout reply" ) ;
95+ assert_eq ! (
96+ AuthCalloutError :: WireFormat ( "x" . into( ) ) . to_string( ) ,
97+ "auth callout wire format error: x"
10598 ) ;
106- assert ! ( AuthCalloutError :: Internal ( "x" . into( ) ) . to_string( ) . contains ( "internal" ) ) ;
99+ assert_eq ! ( AuthCalloutError :: Internal ( "x" . into( ) ) . to_string( ) , "internal error: x" ) ;
107100}
0 commit comments