Пример #1
0
// Check that an update key is working as expected
func TestVerifyUpdateKey(t *testing.T) {
	userName := usersName[0]
	newSecret := secretCode + "aa"

	initAListOfUsers(t, usersName)
	url := listener + ServicePath + fmt.Sprintf(cr.ConvertCommandToRequest(urlCommands[handleUserUpdateCommand]), usersPath, userName, keyToken)
	okUrlJ := cr.Url{Url: fmt.Sprintf("%v/%v", ServicePath, userName)}
	secret, _ := json.Marshal(cr.Secret{Secret: newSecret})
	exeCommandCheckRes(t, cr.PATCH_STR, url, http.StatusCreated, string(secret), okUrlJ)

	OcraData, _ := ocra.NewOcraUser([]byte(newSecret), internalOcraSuite)
	url = resourcePath + "/" + userName
	exeCommandCheckRes(t, cr.GET_STR, url, http.StatusOK, "", OcraData)
}
func GenerateUserData(el *EntityManager, usersName []string, secret []byte, salt []byte) {
	el.AddUser(usersName[0])
	amData, _ := am.NewUserAm(am.SuperUserPermission, secret, salt)
	el.AddPropertyToEntity(usersName[0], stc.AmPropertyName, amData)
	otpData, _ := otp.NewSimpleOtpUser(secret)
	el.AddPropertyToEntity(usersName[0], stc.OtpPropertyName, otpData)
	pwdData, _ := password.NewUserPwd(secret, salt)
	el.AddPropertyToEntity(usersName[0], stc.PwdPropertyName, pwdData)
	ocraData, _ := ocra.NewOcraUser([]byte("ABCD1234"), "OCRA-1:HOTP-SHA512-8:C-QH08-T1M-S064-PSHA256")
	el.AddPropertyToEntity(usersName[0], stc.OcraPropertyName, ocraData)

	el.AddUser(usersName[1])
	el.AddPropertyToEntity(usersName[1], stc.OtpPropertyName, otpData)
}
Пример #3
0
// 2. Check that an update ocraSuite is working as expected
func TestVerifyUpdateOcraSuite(t *testing.T) {
	userName := usersName[0]
	newOcra := "OCRA-1:HOTP-SHA512-8:C-QH08-T1M-S064-PSHA256"

	initAListOfUsers(t, usersName)

	url := listener + ServicePath + fmt.Sprintf(cr.ConvertCommandToRequest(urlCommands[handleUserUpdateCommand]), usersPath, userName, ocraSuiteToken)
	okUrlJ := cr.Url{Url: fmt.Sprintf("%v/%v", ServicePath, userName)}
	str, _ := json.Marshal(cr.StringMessage{Str: newOcra})
	exeCommandCheckRes(t, cr.PATCH_STR, url, http.StatusCreated, string(str), okUrlJ)

	OcraData, _ := ocra.NewOcraUser([]byte(secretCode), newOcra)
	url = resourcePath + "/" + userName
	exeCommandCheckRes(t, cr.GET_STR, url, http.StatusOK, "", OcraData)
}
Пример #4
0
func (o ocraRestful) restAddOcra(request *restful.Request, response *restful.Response) {
	var OcraData OcraUserData
	name := request.PathParameter(userIdParam)

	err := request.ReadEntity(&OcraData)
	if err != nil {
		o.setError(response, http.StatusBadRequest, err)
		return
	}
	data, err := ocra.NewOcraUser([]byte(OcraData.Secret), OcraData.OcraSuite)
	if err != nil {
		o.setError(response, http.StatusBadRequest, err)
		return
	}
	o.st.UsersList.AddPropertyToEntity(name, stc.OcraPropertyName, data)
	response.WriteHeader(http.StatusCreated)
	response.WriteEntity(o.getUrlPath(request, name))
}
Пример #5
0
func Test_AddCheckRemoveOcraUserProperty(t *testing.T) {
	moduleData, _ := ocra.NewOcraUser([]byte("12345678"), "OCRA-1:HOTP-SHA512-8:C-QH08-T1M-S064-PSHA256")

	testAddCheckRemoveUserProperty(t, stc.OcraPropertyName, moduleData)
}