func Test_Exercise_Settings_Update(t *testing.T) {
	user := mockUser()
	initUser(user)
	exercise := mockExercise()
	initExercise(exercise)
	defaultSettings := map[string]string{
		"backgroundColorMenuBar": "#ccc",
		"fontColorMenuBar":       "#555",
		"newsStationEnabled":     "true",
		"twitterEnabled":         "true",
		"facebookEnabled":        "false",
		"youtubeEnabled":         "false",
		"usaidEnabled":           "false",
		"dosEnabled":             "true",
		"contactEnabled":         "true",
		"contactDestination":     "*****@*****.**",
		"arcgisMainMapLink":      "",
		"arcgisEmbed":            "true",
		"key":                    "value",
	}
	settings, err := models.UpdateExerciseSetting(dbConn(), exercise.Id, defaultSettings)
	if err != nil {
		t.Fatalf("Settings update failed")
	}

	if settings["key"] != "value" {
		t.Fatalf("Settings check failed! %v", settings)
	}

	settings2, err := models.FindOrInitSettingsForExercise(dbConn(), exercise.Id)
	if err != nil {
		t.Fatalf("Settings fetch failed")
	}
	if settings2["key"] != "value" {
		t.Fatalf("Settings check failed! %v", settings2)
	}

}
func (h *Handler) authenticationUpdateExercisesSettings(w http.ResponseWriter, r *http.Request, u *sitrep.UsersByEmail, exercise *sitrep.ExerciseByIdentifier) {
	exercises, err := models.FindExercisePermissionsForUser(h.Cassandra, u, exercise)
	if err != nil {
		httpError(w, "User is not authorized in this exercise at all!", false, http.StatusUnauthorized)
		return
	}
	if !exercises.IsAdmin || !u.IsAdmin {
		httpError(w, "User is authorized to update settings", false, http.StatusUnauthorized)
		return
	}
	req, err := unmarshalSettingsUpdateRequest(r)
	if err != nil {
		httpError(w, "Error occured while processing your settings!", false, http.StatusInternalServerError)
		return
	}
	updated, err := models.UpdateExerciseSetting(h.Cassandra, exercise.Id, req.Values)
	if err != nil {
		httpError(w, "Error occured while saving your settings!", false, http.StatusInternalServerError)
		return
	}
	w.Header().Add("content-type", "application/json")
	w.Write(MarshalJSON(updated, false))
}