Robotframework:如何执行令牌和对来自String的不同变量的秘密处理?

时间:2018-09-12 17:58:23

标签: python automation robotframework

我收到一个响应,并将其转换为字符串

public function loginUser($username, $password)
{
    $loginData = array(
        'uname' => $username,
        'uident_text' => $password,
        'status' => 'login'
    );

    $GLOBALS['TSFE']->fe_user->checkPid = 0;
    $info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
    $userAuth = $this->objectManager->get(FrontendUserAuthentication::class);
    $user = $userAuth->fetchUserRecord($info['db_user'], $loginData['uname']);

    if ($user) {
        $userAuth->checkPid = false;
        $isValidLoginData = $this->saltedPasswordService->compareUident($user, $loginData);

        if (!$isValidLoginData) {
            return false;
        } else {
            $GLOBALS['TSFE']->fe_user->forceSetCookie = TRUE;
            $GLOBALS['TSFE']->fe_user->dontSetCookie = false;
            $GLOBALS['TSFE']->fe_user->start();
            $GLOBALS['TSFE']->fe_user->createUserSession($user);
            $GLOBALS['TSFE']->fe_user->setAndSaveSessionData('dummy', TRUE);
            $GLOBALS['TSFE']->fe_user->loginUser = 1;
            return true;
        }
    } else {
        return false;
    }
}

我该如何保存并保存到不同的变量中? 非常感谢。

1 个答案:

答案 0 :(得分:0)

假设此数据是有效的JSON,则可以将其转换为字典,然后使用漫游器的扩展变量语法

示例:

${result}=  evaluate  json.loads($string)  json

should be equal  ${result["data"]["id"]}      ${NONE}
should be equal  ${result["data"]["type"]}    token
should be equal  ${result["data"]["secret"]}  <SecretID>
should be equal  ${result["data"]["token"]}   <TokenID>