Hi @Moritz_H - welcome to the MongoDB community forums!
I am not a user of mongoc, but having a look at the docs, I think your syntax is slightly off. You wrote:
conn = mongoc("localhost",27017,"test", "UserName", "testUser", "Password", "testPassword");
… but I think it should be:
conn = mongoc("localhost",27017,"test", UserName="testUser", Password="testPassword");
That’s from the MathWorks docs