Skip to content

Commit 885085c

Browse files
author
Christian Hergert
committed
test: test insert and update during authentication failure.
1 parent b2b5c6e commit 885085c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test-mongoc-client.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ test_mongoc_client_authenticate_failure (void)
142142
bson_error_t error;
143143
bool r;
144144
bson_t q;
145+
bson_t empty = BSON_INITIALIZER;
145146

146147
/*
147148
* Try authenticating with that user.
@@ -158,6 +159,25 @@ test_mongoc_client_authenticate_failure (void)
158159
assert(error.domain == MONGOC_ERROR_CLIENT);
159160
assert(error.code == MONGOC_ERROR_CLIENT_AUTHENTICATE);
160161
mongoc_cursor_destroy(cursor);
162+
163+
/*
164+
* Try various commands while in the failed state to ensure we get the
165+
* same sort of errors.
166+
*/
167+
r = mongoc_collection_insert (collection, 0, &empty, NULL, &error);
168+
assert (!r);
169+
assert (error.domain == MONGOC_ERROR_CLIENT);
170+
assert (error.code == MONGOC_ERROR_CLIENT_AUTHENTICATE);
171+
172+
/*
173+
* Try various commands while in the failed state to ensure we get the
174+
* same sort of errors.
175+
*/
176+
r = mongoc_collection_update (collection, 0, &q, &empty, NULL, &error);
177+
assert (!r);
178+
assert (error.domain == MONGOC_ERROR_CLIENT);
179+
assert (error.code == MONGOC_ERROR_CLIENT_AUTHENTICATE);
180+
161181
mongoc_collection_destroy(collection);
162182
mongoc_client_destroy(client);
163183
}

0 commit comments

Comments
 (0)