/*
Copyright (C) 2015 Red Hat
SSSD tests: Simple access provider tests
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <talloc.h>
#include <tevent.h>
#include <errno.h>
#include <popt.h>
#include <security/pam_appl.h>
#include "tests/cmocka/common_mock.h"
#include "tests/cmocka/common_mock_be.h"
#include "tests/cmocka/common_mock_resp.h"
#include "db/sysdb_private.h" /* new_subdomain() */
#include "providers/simple/simple_access.h"
#include "providers/simple/simple_access_pvt.h"
struct simple_test_ctx {
bool access_granted;
};
{
int ret;
if (simple_test_ctx == NULL) {
return ENOMEM;
}
return ENOMEM;
}
return ENOMEM;
}
return ENOMEM;
}
return ENOMEM;
}
struct dp_req_params);
return ENOMEM;
}
*state = simple_test_ctx;
return 0;
}
struct sss_domain_info *dom,
struct sss_test_conf_param params[])
{
char *cdb_path;
return ENOMEM;
}
break;
}
}
}
return ret;
}
struct sss_domain_info *dom,
struct sss_test_conf_param params[])
{
return ret;
}
return ENOMEM;
}
return EOK;
}
{
}
{
/* make sure there are no leftovers from previous tests */
return 0;
}
{
}
const char *username,
int expected_rv,
bool allow_access)
{
int ret;
/* otherwise the output is undefined */
if (expected_rv == EOK) {
}
}
{
}
{
{ "simple_deny_users", "u1, u2" },
};
}
{
{ "simple_allow_users", "u1, u2" },
};
}
{
{ "simple_allow_users", "u1, u2" },
{ "simple_deny_users", "u1, u2" },
};
params);
}
{
{ "simple_allow_users", "u1, u2" },
};
params);
}
{
{ "simple_allow_users", "u1, u2" },
};
params);
}
{
{ "simple_allow_users", "u1, u2" },
};
params);
}
{
{ "simple_allow_users", "space user, another user@simple_test" },
};
}
{
int ret;
char *u1;
char *u2;
char *u3;
char *g1;
char *g2;
char *sp;
char *sp2;
char *pvt;
return 1;
}
return 1;
}
return 0;
}
{
int ret;
char *u1;
char *u2;
char *u3;
char *g1;
char *g2;
char *sp;
char *sp2;
char *pvt;
return 1;
}
/* make sure there are no leftovers from previous tests */
return 0;
}
{
{ "simple_deny_groups", "g1, g2" },
};
params);
}
{
{ "simple_allow_groups", "g1, g2" },
};
}
{
{ "simple_allow_groups", "g1, g2" },
{ "simple_deny_groups", "g1, g2" },
};
}
{
{ "simple_allow_groups", "G1, G2" },
};
params);
}
{
{ "simple_allow_groups", "G1, G2" },
};
params);
/* Case-sensitive domain, wrong case */
}
{
{ "simple_allow_users", "u1, user@no.such.domain" },
};
params);
/* Case-sensitive domain, wrong case */
/* A user that would normally be denied access will be denied because
* the access list can't be parsed
*/
/* A user that would normally be allowed access will be denied because
* the access list can't be parsed
*/
}
{
{ "simple_deny_users", "u2, user@no.such.domain" },
};
params);
/* Case-sensitive domain, wrong case */
/* A user that would normally be denied access will be denied because
* the access list can't be parsed
*/
/* A user that would normally be allowed access will be denied because
* the access list can't be parsed
*/
}
{
{ "simple_allow_groups", "g1, group@no.such.domain" },
};
params);
/* Case-sensitive domain, wrong case */
/* A group that would normally be denied access will be denied because
* the access list can't be parsed
*/
/* A group that would normally be allowed access will be denied because
* the access list can't be parsed
*/
}
{
{ "simple_deny_groups", "g2, group@no.such.domain" },
};
params);
/* Case-sensitive domain, wrong case */
/* A group that would normally be denied access will be denied because
* the access list can't be parsed
*/
/* A group that would normally be allowed access will be denied because
* the access list can't be parsed
*/
}
{
{ "simple_allow_groups", "space group, another space@simple_test" },
};
}
{
int rv;
int no_cleanup = 0;
int opt;
_("Do not delete the test database after a test run"), NULL },
};
};
/* Set debug level to invalid value so we can decide if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old DB to be sure */
if (rv == 0 && !no_cleanup) {
}
return rv;
}