func ensureVirtualUserRegistered(t *testing.T, c *client.CSAPI, virtualUserLocalpart string) {
	res := c.DoFunc(
		t,
		"POST",
		[]string{"_matrix", "client", "r0", "register"},
		client.WithJSONBody(t, map[string]interface{}{"type": "m.login.application_service", "username": virtualUserLocalpart}),
		client.WithContentType("application/json"),
	)

	if res.StatusCode == 200 {
		return
	}

	body := client.ParseJSON(t, res)
	errcode := client.GetJSONFieldStr(t, body, "errcode")

	if res.StatusCode == 400 && errcode == "M_USER_IN_USE" {
		return
	} else {
		errorMessage := client.GetJSONFieldStr(t, body, "error")
		t.Fatalf("msc2716.ensureVirtualUserRegistered failed to register: (%s) %s", errcode, errorMessage)
	}
}
// ensureVirtualUserRegistered makes sure the user is registered for the homeserver regardless
// if they are already registered or not. If unable to register, fails the test
ensureVirtualUserRegistered makes sure the user is registered for the homeserver regardless
if they are already registered or not. If unable to register, fails the test
// ensureVirtualUserRegistered makes sure the user is registered for the homeserver regardless // if they are already registered or not . If unable to register fails the test
func ensureVirtualUserRegistered(t *testing.T, c *client.CSAPI, virtualUserLocalpart string) {
	res := c.DoFunc(
		t,
		"POST",
		[]string{"_matrix", "client", "r0", "register"},
		client.WithJSONBody(t, map[string]interface{}{"type": "m.login.application_service", "username": virtualUserLocalpart}),
		client.WithContentType("application/json"),
	)
	if res.StatusCode == 200 {
		return
	}
	body := client.ParseJSON(t, res)
	errcode := client.GetJSONFieldStr(t, body, "errcode")
	if res.StatusCode == 400 && errcode == "M_USER_IN_USE" {
		return
	} else {
		errorMessage := client.GetJSONFieldStr(t, body, "error")
		t.Fatalf("msc2716.ensureVirtualUserRegistered failed to register: (%s) %s", errcode, errorMessage)
	}
}
func ensureVirtualUserRegistered ( t * testing . T , c * client . CSAPI , virtualUserLocalpart string ) { res := c . DoFunc ( t , " " , [ ] string { " " , " " , " " , " " } , client . WithJSONBody ( t , map [ string ] interface { } { " " : " " , " " : virtualUserLocalpart } ) , client . WithContentType ( " " ) , ) if res . StatusCode == 200 { return } body := client . ParseJSON ( t , res ) errcode := client . GetJSONFieldStr ( t , body , " " ) if res . StatusCode == 400 && errcode == " " { return } else { errorMessage := client . GetJSONFieldStr ( t , body , " " ) t . Fatalf ( " " , errcode , errorMessage ) } }
ensureVirtualUserRegistered makes sure the user is registered for the homeserver regardless
if they are already registered or not.
ensureVirtualUserRegistered makes sure the user is registered for the homeserver regardless if they are already registered or not .