aboutsummaryrefslogtreecommitdiff
path: root/test/interop/username_and_password_test.c
blob: 6e0eaab1579928a003b6816ddf3ecdee700bdf86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "greatest.h"
#include "testclient.h"
#include "cleanup.c"
#include "topics.c"

TEST username_and_password_test()
{
    TestClient *client;

    client = TestClientNew("clienta");
    ASSERT_EQ(0, MqttClientSetAuth(client->client, "myusername", NULL));
    ASSERT(TestClientConnect(client, "localhost", 1883, 60, 1));
    TestClientDisconnect(client);
    ASSERT_EQ(0, MqttClientSetAuth(client->client, "myusername", "mypassword"));
    ASSERT(TestClientConnect(client, "localhost", 1883, 60, 1));
    TestClientDisconnect(client);
    TestClientFree(client);

    PASS();
}

GREATEST_MAIN_DEFS();

int main(int argc, char **argv)
{
    GREATEST_MAIN_BEGIN();
    cleanup();
    RUN_TEST(username_and_password_test);
    GREATEST_MAIN_END();
}