use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class Issue619Test method testGetPolicyDecision.
@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "resourceName", "actionName" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String resourceName, String actionName) throws Exception {
entering("testGetPolicyDecision()", null);
log(Level.INFO, "orgName:", orgName);
log(Level.INFO, "userName:", userName);
log(Level.INFO, "password:", password);
log(Level.INFO, "serviceName:", serviceName);
log(Level.INFO, "resourceName:", resourceName);
log(Level.INFO, "actionName:", actionName);
SSOToken token = TokenUtils.getSessionToken(orgName, userName, password);
log(Level.INFO, "Created ssoToken", "\n");
PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().getPolicyEvaluator(serviceName);
Map env = new HashMap();
Set attrSet = new HashSet();
//attrSet.add(invocatorUuid);
log(Level.INFO, "set auth level in envMap as a set containing " + "/:1, /:2", "\n");
attrSet.add("/:1");
attrSet.add("/:2");
env.put(Condition.REQUEST_AUTH_LEVEL, attrSet);
log(Level.INFO, "env Map:" + env, "\n");
Set actions = new HashSet();
actions.add(actionName);
PolicyDecision pd = pe.getPolicyDecision(token, resourceName, actions, env);
log(Level.INFO, "PolicyDecision XML:", pd.toXML());
entering("testGetPolicyDecision()", null);
}
use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class Issue736Test method testGetPolicyDecision.
@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "actionName" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String actionName) throws Exception {
entering("Issue736Test.testGetPolicyDecision()", null);
String resourceName = "http://host1.sample.com:80/banner.html";
log(Level.INFO, "orgName:", orgName);
log(Level.INFO, "userName:", userName);
log(Level.INFO, "password:", password);
log(Level.INFO, "serviceName:", serviceName);
log(Level.INFO, "resourceName:", resourceName);
log(Level.INFO, "actionName:", actionName);
SSOToken token = TokenUtils.getSessionToken(orgName, userName, password);
log(Level.INFO, "Created ssoToken", "\n");
PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().getPolicyEvaluator(serviceName);
Set actions = new HashSet();
actions.add(actionName);
PolicyDecision pd = pe.getPolicyDecision(token, resourceName, actions, //null envMap
null);
log(Level.INFO, "PolicyDecision XML:", pd.toXML());
entering("testGetPolicyDecision()", null);
}
use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class PolicyEvaluatorTest method testGetPolicyDecision.
@Test(groups = { "policy-client" })
@Parameters({ "orgName", "userName", "password", "serviceName", "resourceName", "actionName" })
public void testGetPolicyDecision(String orgName, String userName, String password, String serviceName, String resourceName, String actionName) throws Exception {
entering("testGetPolicyDecision()", null);
log(Level.INFO, "orgName:", orgName);
log(Level.INFO, "userName:", userName);
log(Level.INFO, "password:", password);
log(Level.INFO, "serviceName:", serviceName);
log(Level.INFO, "resourceName:", resourceName);
log(Level.INFO, "actionName:", actionName);
SSOToken token = TokenUtils.getSessionToken(orgName, userName, password);
log(Level.INFO, "Created ssoToken", "\n");
PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().getPolicyEvaluator(serviceName);
Map env = new HashMap();
Set attrSet = new HashSet();
//attrSet.add(invocatorUuid);
env.put("invocatorPrincipalUuid", attrSet);
log(Level.INFO, "env Map:" + env, "\n");
Set actions = new HashSet();
actions.add(actionName);
PolicyDecision pd = pe.getPolicyDecision(token, resourceName, actions, env);
log(Level.INFO, "PolicyDecision XML:", pd.toXML());
entering("testGetPolicyDecision()", null);
}
use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class AMLogTest method setup.
/**
* Before running the test(s), ensure:
* o the log svc config is set with buffer timer off, buff size = 1
*
* @throws Exception if an AMLogException occurs
*/
@Parameters({ "logtest-log-location", "logtest-logname" })
@BeforeTest(groups = { "api-adminwrite", "api-adminread" })
public void setup(String logLoc, String logFName) throws Exception {
Object[] params = { theRealm, logLoc, logFName };
entering("setup", params);
setbufferSizer("OFF", "1");
try {
lmgr.readConfiguration();
String tlogLoc = lmgr.getProperty(LogConstants.LOG_LOCATION);
if ((tlogLoc == null) || (tlogLoc.length() == 0)) {
tlogLoc = logLoc;
}
if ((logFName != null) && (logFName.length() > 0)) {
logName = logFName;
} else {
logName = defaultLogName;
}
loggingLocation = tlogLoc;
logPath = loggingLocation + "/" + logName;
File f1 = new File(logPath);
if (f1.exists() && (f1.length() > 0)) {
f1.delete();
}
logger = (Logger) Logger.getLogger(logFName);
} catch (Exception e) {
log(Level.SEVERE, "setup", e.getMessage(), params);
e.printStackTrace();
throw e;
}
exiting("setup");
}
use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class AMLogTest method writeAdminLogRecord.
/**
* need:
* only the amadmin SSOToken (used in LogRecord), since
* can't (currently) use user SSOTokens. also means
* the log delegation can't be tested.
* column values
* data
* module_name
* domain
* log_level
* login_id
* ip_addr
* host_name
* message_id
* number of records to write
*
*/
@Parameters({ "logwrite-data", "logwrite-modulename", "logwrite-domain", "logwrite-log-level", "logwrite-login-id", "logwrite-ip-addr", "logwrite-host-name", "logwrite-message-id", "logwrite-number-of-records" })
@Test(groups = { "api-adminwrite" })
public void writeAdminLogRecord(String rData, String rModuleName, String rDomain, String rLogLevel, String rLoginId, String rIPAddr, String rHostName, String rMsgId, String rNumRecs) throws AMLogException {
LogRecord lR = null;
Level llevel = null;
int numRecs = 0;
if ((rNumRecs != null) && (rNumRecs.length() > 0)) {
try {
numRecs = Integer.parseInt(rNumRecs);
} catch (NumberFormatException nfe) {
log(Level.WARNING, "writeAdminLogRecord", nfe.getMessage());
numRecs = 1;
}
}
llevel = getLogLevel(rLogLevel);
/**
* DOMAIN, LOGIN_ID, IP_ADDR, and HOST_NAME are extracted from the
* SSOToken and added by the LogRecord handling. if any values are
* provided to the test, then they'll be added.
*/
int totalRecs = 0;
SSOToken adminToken = getAdminSSOToken();
/*
* put variable data in ("msgDataPrefix + i") reverse
* order, so we can test sortBy in the read test.
*/
for (int i = (numRecs - 1); i >= 0; i--) {
lR = new LogRecord(llevel, msgDataPrefix + i + "|" + rData, adminToken);
if ((rDomain != null) && (rDomain.length() > 0)) {
lR.addLogInfo(LogConstants.DOMAIN, rDomain);
}
// ignore rLoginId parameter; use "amAdmin"
lR.addLogInfo(LogConstants.LOGIN_ID, "amAdmin");
if ((rIPAddr != null) && (rIPAddr.length() > 0)) {
lR.addLogInfo(LogConstants.IP_ADDR, rIPAddr);
}
if ((rHostName != null) && (rHostName.length() > 0)) {
lR.addLogInfo(LogConstants.HOST_NAME, rHostName);
}
if ((rModuleName != null) && (rModuleName.length() > 0)) {
lR.addLogInfo(LogConstants.MODULE_NAME, rModuleName);
}
if ((rMsgId != null) && (rMsgId.length() > 0)) {
String msgid = rMsgId + i;
lR.addLogInfo(LogConstants.MESSAGE_ID, msgid);
}
try {
logger.log(lR, adminToken);
totalRecs++;
} catch (AMLogException alex) {
// unexpected exception
log(Level.SEVERE, "writeAdminLogRecord", alex.getMessage());
throw alex;
}
}
}
Aggregations