Skip to content

Commit c0b4391

Browse files
authored
Update /scram/auth_tests to handle SCRAM-SHA-256 error messages (#1210)
1 parent 8eaac64 commit c0b4391

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/libmongoc/tests/test-mongoc-scram.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,24 @@ typedef enum {
267267
void
268268
_check_error (const bson_error_t *error, test_error_t expected_error)
269269
{
270-
int32_t domain = 0;
271-
int32_t code = 0;
270+
uint32_t domain = 0;
271+
uint32_t code = 0;
272272
const char *message = "";
273273

274274
switch (expected_error) {
275-
case MONGOC_TEST_AUTH_ERROR:
275+
case MONGOC_TEST_AUTH_ERROR: {
276276
domain = MONGOC_ERROR_CLIENT;
277277
code = MONGOC_ERROR_CLIENT_AUTHENTICATE;
278-
message = "Authentication failed";
278+
ASSERT_CMPUINT32 (error->domain, ==, domain);
279+
ASSERT_CMPUINT32 (error->code, ==, code);
280+
const char *const a = "Authentication failed";
281+
const char *const b = "Unable to use";
282+
const bool found =
283+
strstr (error->message, a) || strstr (error->message, b);
284+
ASSERT_WITH_MSG (
285+
found, "[%s] does not contain [%s] or [%s]", error->message, a, b);
279286
break;
287+
}
280288
case MONGOC_TEST_USER_NOT_FOUND_ERROR:
281289
domain = MONGOC_ERROR_CLIENT;
282290
code = MONGOC_ERROR_CLIENT_AUTHENTICATE;

0 commit comments

Comments
 (0)