Exemplo n.º 1
0
func TestUserRequest(t *testing.T) {
	//request 1 : unscoped password authentication
	request1Raw := `{"user":{"name":"James Doe","domain_id":"1789d1","default_project_id":"263fd9","email":"*****@*****.**","description":"James Doe user","password":"******","enabled":true}}`
	request1Struct := &UserRequest{
		User: &User{
			DefaultProjectId: "263fd9",
			Description:      "James Doe user",
			DomainId:         "1789d1",
			Email:            "*****@*****.**",
			Enabled:          true,
			Name:             "James Doe",
			Password:         "******",
		},
	}

	request1Unmarshal := &UserRequest{}
	err := json.Unmarshal([]byte(request1Raw), request1Unmarshal)

	testutil.IsNil(t, err)
	testutil.Equals(t, request1Struct, request1Unmarshal)

	request1Marshal, err := json.Marshal(request1Struct)
	testutil.IsNil(t, err)
	testutil.Equals(t, request1Raw, string(request1Marshal))
}
Exemplo n.º 2
0
func TestUnmarshalValidTimeTest(t *testing.T) {
	val := timeTest{}
	err := json.Unmarshal([]byte(testValue), &val)
	testutil.IsNil(t, err)
	testutil.Equals(t, timeTestValue.CreatedAt.Time, val.CreatedAt.Time)
}
Exemplo n.º 3
0
func TestUserResponse(t *testing.T) {
	response1Raw := `{
    "user": {
        "default_project_id": "263fd9",
        "description": "James Doe user",
        "domain_id": "1789d1",
        "email": "*****@*****.**",
        "enabled": true,
        "id": "ff4e51",
        "links": {
            "self": "https://*****:*****@example.com",
			Enabled:          true,
			Name:             "James Doe",
			Id:               "ff4e51",
			Links: Link{
				"self": "https://*****:*****@example.com",
				"enabled": true,
				"id": "4ab84ab39de54f4d96eaff8f2145a7cd",
				"links": {
					"self": "http://*****:*****@example.com",
				Enabled:  true,
				Name:     "swiftusertest1",
				Id:       "4ab84ab39de54f4d96eaff8f2145a7cd",
				Links: Link{
					"self": "http://localhost:5000/v3/users/4ab84ab39de54f4d96eaff8f2145a7cd",
				},
			},
		},
	}

	response2Unmarshal := &UsersResponse{}
	err = json.Unmarshal([]byte(response2Raw), response2Unmarshal)
	testutil.IsNil(t, err)
	testutil.Equals(t, response2Struct, response2Unmarshal)

}