예제 #1
0
void test_user_is_in_group_false_when_user_not_in_group(CuTest *tc)
{
    int is_in_group;

    setup();
    is_in_group = user_is_in_group("tom", "user", "second");
    CuAssertIntEquals(tc, 0, is_in_group);
    teardown();
}
예제 #2
0
void test_user_is_in_group_true_when_user_in_group(CuTest *tc)
{
    int is_in_group;

    setup();
    is_in_group = user_is_in_group("bob", "user", "second");
    CuAssertIntEquals(tc, 1, is_in_group);
    teardown();
}
예제 #3
0
void test_user_group_add_fails_for_invalid_user(CuTest *tc)
{
    int is_in_group;

    setup();
    user_set_group("frank", "admin", "second");
    is_in_group = user_is_in_group("frank", "admin", "second");
    CuAssertIntEquals(tc, 0, is_in_group);
    teardown();
}
예제 #4
0
void test_user_group_add_succeeds_for_valid_user_group(CuTest *tc)
{
    int is_in_group;

    setup();
    user_set_group("bob", "admin", "second");
    is_in_group = user_is_in_group("bob", "admin", "second");
    CuAssertIntEquals(tc, 1, is_in_group);
    teardown();
}
예제 #5
0
char *getoption_group(char *name)
{
    char *result;
    struct group_of_users *grp;
    if ((grp = config_groups)) {
        do {
            if (user_is_in_group(grp) && grp->options) {
                if ((result = getoption_directories(grp->directories, name)))
                    return result;
                if ((result = getoption(grp->options, name)))
                    return result;
            }
        } while ((grp = grp->next));
    }
    return NULL;
}
예제 #6
0
int add_user_to_group(const char *user, const char *group,  const char *animal)
{
    char **groups;
    int i;

    user_set_group(user, group, animal);
    if (user_is_in_group(user, group, animal) == 0) {
        fprintf(stderr, "Failed to add %s to %s in %s.\n", user, group, animal);
        return EXIT_FAILURE;
    }

    groups = user_get_groups(user, animal);
    printf("User %s has the following groups on %s:\n", user, animal);

    for(i=0; groups[i]; ++i) {
        printf("  %s\n", groups[i]);
    }

    return EXIT_SUCCESS;
}
예제 #7
0
파일: userlist.c 프로젝트: bf4/pidgin-mac
static gboolean
user_is_there(MsnUser *user, int list_id, int group_id)
{
	int list_op;

	if (user == NULL)
		return FALSE;

	list_op = 1 << list_id;

	if (!(user->list_op & list_op))
		return FALSE;

	if (list_id == MSN_LIST_FL)
	{
		if (group_id >= 0)
			return user_is_in_group(user, group_id);
	}

	return TRUE;
}