コード例 #1
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}
	switch okJ.(type) {
	case *ocra.UserOcra:
		var user ocra.UserOcra
		json.Unmarshal([]byte(sData), &user)
		data, _ := json.Marshal(user)
		res = string(data)
		data, _ = json.Marshal(okJ.(*ocra.UserOcra))
		exp = string(data)
	case *OcraData:
		var oData OcraData
		json.Unmarshal([]byte(sData), &oData)
		data, _ := json.Marshal(oData)
		res = string(data)
		data, _ = json.Marshal(okJ.(*OcraData))
		exp = string(data)
	default:
		panic(fmt.Sprintf("Error unknown type: value: %v", okJ))
	}

	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}
コード例 #2
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}

	switch okJ.(type) {
	case *password.UserPwd: // expiration time is not compared
		res = cr.RemoveSpaces(string(sData))
		var user password.UserPwd
		json.Unmarshal([]byte(sData), &user)
		user.Expiration = okJ.(*password.UserPwd).Expiration
		if reflect.DeepEqual(user, okJ.(*password.UserPwd)) == false {
			data, _ := json.Marshal(okJ.(*password.UserPwd))
			exp = string(data)
		} else {
			exp = res
		}
	default:
		panic(fmt.Sprintf("Error unknown type: value: %v", okJ))
	}

	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}
コード例 #3
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}

	switch okJ.(type) {
	case itemValue:
		var val itemValue
		err = json.Unmarshal([]byte(sData), &val)
		res = fmt.Sprintf("%v", val.Data)
		exp = fmt.Sprintf("%v", okJ.(itemValue).Data)
	case ss.SecureStorage:
		var data ss.SecureStorage
		err = json.Unmarshal([]byte(sData), &data)
		res = fmt.Sprintf("%v", data.Data)
		exp = fmt.Sprintf("%v", okJ.(ss.SecureStorage).Data)
	default:
		panic(fmt.Sprintf("Error unknown type: value: %v", okJ))
	}

	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}
コード例 #4
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}

	switch okJ.(type) {
	case *otp.OtpUser:
		var user otp.OtpUser
		json.Unmarshal([]byte(sData), &user)
		data, _ := json.Marshal(user)
		res = string(data)
		data, _ = json.Marshal(okJ.(*otp.OtpUser))
		exp = string(data)
	case userState:
		var state userState
		err = json.Unmarshal([]byte(sData), &state)
		res = fmt.Sprintf("%v", state.Blocked)
		exp = fmt.Sprintf("%v", okJ.(userState).Blocked)
	default:
		panic(fmt.Sprintf("Error unknown type: %v", okJ))
	}

	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}
コード例 #5
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}

	switch okJ.(type) {
	case *am.AmUserInfo:
		var user am.AmUserInfo
		err = json.Unmarshal([]byte(sData), &user)
		res = fmt.Sprintf("%v-%v", user.Privilege, user.Pwd.Password)
		exp = fmt.Sprintf("%v-%v", okJ.(*am.AmUserInfo).Privilege, okJ.(*am.AmUserInfo).Pwd.Password)
	default:
		panic(fmt.Sprintf("Error unknown type: value: %v", okJ))
	}

	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}
コード例 #6
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}

	switch okJ.(type) {
	case *acl.Acl:
		var a1 *acl.Acl
		json.Unmarshal([]byte(sData), &a1)
		data, _ := json.Marshal(a1)
		res = string(data)
		data, _ = json.Marshal(okJ.(*acl.Acl))
		exp = string(data)
	default:
		panic(fmt.Sprintf("Error unknown type: value: %v", okJ))
	}

	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}
コード例 #7
0
func getExpectedData(sData string, okJ interface{}) (string, string, cr.Error, error) {
	found, exp, res, e, err := cr.GetExpectedData(sData, okJ)
	if found == true {
		return exp, res, e, err
	}
	switch okJ.(type) {
	case en.EntityManager:
		res = cr.RemoveSpaces(string(sData))
		d1, _ := json.Marshal(okJ.(en.EntityManager))
		var us en.EntityManager
		json.Unmarshal([]byte(sData), &us)
		if reflect.DeepEqual(us, okJ.(en.EntityManager)) == false {
			exp = string(d1)
		} else {
			exp = res
		}
	default:
		panic(fmt.Sprintf("Error unknown type: value: %v", okJ))
	}
	if err != nil {
		err = json.Unmarshal([]byte(sData), &e)
	}
	return exp, res, e, err
}