Search in sources :

Example 1 with Parameters

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);
}
Also used : PolicyDecision(com.sun.identity.policy.PolicyDecision) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) PolicyEvaluator(com.sun.identity.policy.client.PolicyEvaluator) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with Parameters

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);
}
Also used : PolicyDecision(com.sun.identity.policy.PolicyDecision) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) PolicyEvaluator(com.sun.identity.policy.client.PolicyEvaluator) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with Parameters

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);
}
Also used : PolicyDecision(com.sun.identity.policy.PolicyDecision) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) PolicyEvaluator(com.sun.identity.policy.client.PolicyEvaluator) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 4 with Parameters

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");
}
Also used : File(java.io.File) AMLogException(com.sun.identity.log.AMLogException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) Parameters(org.testng.annotations.Parameters) BeforeTest(org.testng.annotations.BeforeTest)

Example 5 with Parameters

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;
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogRecord(com.sun.identity.log.LogRecord) AMLogException(com.sun.identity.log.AMLogException) Level(java.util.logging.Level) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Aggregations

Parameters (org.testng.annotations.Parameters)1840 Test (org.testng.annotations.Test)1766 BaseTest (org.gluu.oxauth.BaseTest)1103 RegisterRequest (org.gluu.oxauth.client.RegisterRequest)781 RegisterResponse (org.gluu.oxauth.client.RegisterResponse)771 RegisterClient (org.gluu.oxauth.client.RegisterClient)717 ResponseType (org.gluu.oxauth.model.common.ResponseType)648 Response (javax.ws.rs.core.Response)537 Builder (javax.ws.rs.client.Invocation.Builder)532 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)532 AuthorizationResponse (org.gluu.oxauth.client.AuthorizationResponse)530 AuthorizationRequest (org.gluu.oxauth.client.AuthorizationRequest)525 BaseTest (org.xdi.oxauth.BaseTest)511 OxAuthCryptoProvider (org.gluu.oxauth.model.crypto.OxAuthCryptoProvider)418 TokenRequest (org.gluu.oxauth.client.TokenRequest)265 ResponseType (org.xdi.oxauth.model.common.ResponseType)259 TokenResponse (org.gluu.oxauth.client.TokenResponse)247 TokenClient (org.gluu.oxauth.client.TokenClient)242 JSONException (org.codehaus.jettison.json.JSONException)238 URISyntaxException (java.net.URISyntaxException)235