File: test_access.c

package info (click to toggle)
siridb-server 2.0.53-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,612 kB
  • sloc: ansic: 47,501; python: 6,263; sh: 254; makefile: 149
file content (39 lines) | stat: -rw-r--r-- 1,129 bytes parent folder | download | duplicates (4)
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
31
32
33
34
35
36
37
38
39
#include "../test.h"
#include <siri/db/access.h>


int main()
{
    test_start("access");

    char buffer[SIRIDB_ACCESS_STR_MAX];
    uint32_t access_bit = 0;

    siridb_access_to_str(buffer, access_bit);
    _assert (strcmp(buffer, "no access") == 0);

    access_bit |= SIRIDB_ACCESS_SHOW;
    siridb_access_to_str(buffer, access_bit);
    _assert (strcmp(buffer, "show") == 0);

    access_bit |= SIRIDB_ACCESS_SELECT;
    siridb_access_to_str(buffer, access_bit);
    _assert (strcmp(buffer, "select and show") == 0);

    access_bit |= SIRIDB_ACCESS_LIST;
    siridb_access_to_str(buffer, access_bit);
    _assert (strcmp(buffer, "list, select and show") == 0);

    access_bit |= SIRIDB_ACCESS_PROFILE_WRITE;
    siridb_access_to_str(buffer, access_bit);
    _assert (strcmp(buffer, "write") == 0);

    access_bit &= ~SIRIDB_ACCESS_INSERT;
    siridb_access_to_str(buffer, access_bit);
    _assert (strcmp(buffer, "read and create") == 0);

    _assert (siridb_access_from_strn("read", 4) == (SIRIDB_ACCESS_PROFILE_READ));
    _assert (siridb_access_from_strn("list", 4) == SIRIDB_ACCESS_LIST);

    return test_end();
}