Verified Commit 6ef5a287 authored by Brian Conway's avatar Brian Conway
Browse files

Linter fixes

- Use staticcheck and gometalinter via Makefile.
- Update integration tests with duplicate names.
- All test variations pass.
parent e387f550
Copyright (c) 2015-2018 Brian Conway <bconway@rcesoftware.com>
Copyright (c) 2015-2019 Brian Conway <bconway@rcesoftware.com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
......
# Set COMMIT to branch + commit ID and VERGO to Go release
# Supported on BSD make and gmake >= 4, macOS's ancient version is out of luck
COMMIT != git describe --all --long
VERGO != go version|cut -d ' ' -f 3,4|tr ' ' _
COMMIT := $(shell git describe --all --long)
VERGO := $(shell go version|cut -d ' ' -f 3,4|tr ' ' _)
PIE = -buildmode=pie
RFLAG =
......@@ -14,15 +12,22 @@ endif
build: get
go build $(PIE) -ldflags "-X main.vercommit=$(COMMIT) \
-X main.vergo=$(VERGO)" $(RFLAG)
go get -u honnef.co/go/tools/cmd/megacheck
megacheck -simple.exit-non-zero -unused.exported ./...
get:
go get -d -u ./...
lint:
go get -u honnef.co/go/tools/cmd/staticcheck
staticcheck ./...
# Run staticcheck before installing gometalinter, as its vendored version will
# overwrite the former.
go get -u github.com/alecthomas/gometalinter
gometalinter -i
gometalinter --fast -t --vendor ./...
# -count 1 is the idiomatic way to disable test caching in package list mode
test: get
go test -count 1 -cover $(RFLAG) ./...
test: get lint
go test -count 1 -cover $(RFLAG) -cpu 1,4 ./...
clean:
go clean
......@@ -52,7 +52,7 @@ All configuration is available as environmental variables, with defaults defined
API handlers and their usage are outlined in `main()` and their respective handler code. Seed data includes an 'admin' user with password 'hello123', which can be used to retrieve an API access key. For example, using `curl`:
$ curl -Ssv -u admin:hello123 -H "Accept: application/json" http://localhost:8088/auth|python -m json.tool
$ curl -Ssv -u admin:hello123 -H "Accept: application/json" http://localhost:8080/auth|python -m json.tool
{
"access_keys": [
{
......@@ -78,7 +78,7 @@ API handlers and their usage are outlined in `main()` and their respective handl
Need XML? **Not a problem:**
$ curl -Ssv -u admin:hello123 -H "Accept: application/xml" http://localhost:8088/auth|xmllint --format -
$ curl -Ssv -u admin:hello123 -H "Accept: application/xml" http://localhost:8080/auth|xmllint --format -
<?xml version="1.0"?>
<response>
<user>
......@@ -104,7 +104,7 @@ Need XML? **Not a problem:**
To retrieve a list of user types:
$ curl -Ssv -H "Authorization: Bearer 58556b26-15fa-11e6-9934-c75080fbda3f" -H "Accept: application/json" http://localhost:8088/user_types|python -m json.tool
$ curl -Ssv -H "Authorization: Bearer 58556b26-15fa-11e6-9934-c75080fbda3f" -H "Accept: application/json" http://localhost:8080/user_types|python -m json.tool
[
{
"description": "Administrator",
......@@ -130,7 +130,7 @@ To retrieve a list of user types:
To create a new job:
$ curl -Ssv -H "Authorization: Bearer 58556b26-15fa-11e6-9934-c75080fbda3f" -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://localhost:8088/jobs -d '{ "started_at": "2015-01-01T19:51:41.696346Z", "completed_at": "2017-01-01T19:51:41.696346Z"}'|python -m json.tool
$ curl -Ssv -H "Authorization: Bearer 58556b26-15fa-11e6-9934-c75080fbda3f" -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://localhost:8080/jobs -d '{ "started_at": "2015-01-01T19:51:41.696346Z", "completed_at": "2017-01-01T19:51:41.696346Z"}'|python -m json.tool
{
"completed_at": "2017-01-01T19:51:41.696346Z",
"id": "63d751f6-1fad-4566-9e31-cbda0fd04953",
......
......@@ -11,7 +11,7 @@ const tagName = "env"
// parse sets Config fields based on environmental variables and defaults.
// TODO: Only strings are currently supported, additional type casting needed.
func parse(cfg *Config) {
func parse(cfg interface{}) {
cv := reflect.ValueOf(cfg).Elem()
ct := cv.Type()
......
......@@ -28,7 +28,7 @@ func (a *Auth) AuthHandler() *middleware.BasicAuth {
RunFunc: func(fw response.FormatWriter, r *http.Request,
client *model.User) {
switch {
case r.Method == "GET" && r.URL.Path == "":
case r.Method == http.MethodGet && r.URL.Path == "":
a.handleGetUserAuth(fw, r, client)
default:
response.MethodNotAllowed(fw, r)
......
......@@ -33,17 +33,17 @@ func (j *Job) JobHandler() *middleware.KeyAuth {
RunFunc: func(fw response.FormatWriter, r *http.Request,
client *model.User) {
switch {
case r.Method == "GET" && r.URL.Path == "":
case r.Method == http.MethodGet && r.URL.Path == "":
j.listJobs(fw, r, client)
case r.Method == "POST" && r.URL.Path == "":
case r.Method == http.MethodPost && r.URL.Path == "":
j.createJob(fw, r, client)
case r.Method == "GET":
case r.Method == http.MethodGet:
j.readJob(fw, r, client, r.URL.Path)
case r.Method == "PUT":
case r.Method == http.MethodPut:
j.updateJob(fw, r, client, r.URL.Path)
case r.Method == "PATCH":
case r.Method == http.MethodPatch:
j.patchJob(fw, r, client, r.URL.Path)
case r.Method == "DELETE":
case r.Method == http.MethodDelete:
j.deleteJob(fw, r, client, r.URL.Path)
default:
response.MethodNotAllowed(fw, r)
......
......@@ -33,17 +33,17 @@ func (u *User) UserHandler() *middleware.KeyAuth {
RunFunc: func(fw response.FormatWriter, r *http.Request,
client *model.User) {
switch {
case r.Method == "GET" && r.URL.Path == "":
case r.Method == http.MethodGet && r.URL.Path == "":
u.listUsers(fw, r, client)
case r.Method == "POST" && r.URL.Path == "":
case r.Method == http.MethodPost && r.URL.Path == "":
u.createUser(fw, r, client)
case r.Method == "GET":
case r.Method == http.MethodGet:
u.readUser(fw, r, client, r.URL.Path)
case r.Method == "PUT":
case r.Method == http.MethodPut:
u.updateUser(fw, r, client, r.URL.Path)
case r.Method == "PATCH":
case r.Method == http.MethodPatch:
u.patchUser(fw, r, client, r.URL.Path)
case r.Method == "DELETE":
case r.Method == http.MethodDelete:
u.deleteUser(fw, r, client, r.URL.Path)
default:
response.MethodNotAllowed(fw, r)
......@@ -66,7 +66,7 @@ func (u *User) listUsers(fw response.FormatWriter, r *http.Request,
func (u *User) createUser(fw response.FormatWriter, r *http.Request,
client *model.User) {
// Only admins are allowed to create users.
if client.UserType != "admin" {
if client.UserType != model.AdminType {
response.Forbidden(fw, r)
return
}
......@@ -164,7 +164,7 @@ func (u *User) patchUser(fw response.FormatWriter, r *http.Request,
func (u *User) deleteUser(fw response.FormatWriter, r *http.Request,
client *model.User, id string) {
// Only admins are allowed to delete users.
if client.UserType != "admin" {
if client.UserType != model.AdminType {
response.Forbidden(fw, r)
return
}
......
......@@ -30,9 +30,9 @@ func (ut *UserType) UserTypeHandler() *middleware.KeyAuth {
RunFunc: func(fw response.FormatWriter, r *http.Request,
client *model.User) {
switch {
case r.Method == "GET" && r.URL.Path == "":
case r.Method == http.MethodGet && r.URL.Path == "":
ut.listUserTypes(fw, r)
case r.Method == "GET":
case r.Method == http.MethodGet:
ut.readUserType(fw, r, r.URL.Path)
default:
response.MethodNotAllowed(fw, r)
......
......@@ -7,8 +7,8 @@
## Usage
$ RE_URL=http://localhost:8088 RE_USER=admin RE_PASS=hello123 rake
$ RE_URL=http://localhost:8080 RE_USER=admin RE_PASS=hello123 rake
Or to run a single test file:
$ RE_URL=http://localhost:8088 RE_USER=admin RE_PASS=hello123 ruby users_json_test.rb
$ RE_URL=http://localhost:8080 RE_USER=admin RE_PASS=hello123 ruby users_json_test.rb
......@@ -187,7 +187,7 @@ class TestGetJobIdNotFoundJson < Minitest::Test
def test_id_not_found
assert_equal 404, @code
assert_equal 'Not found', @body['error']
assert_equal 'not found', @body['error']
end
end
......@@ -225,7 +225,7 @@ class TestUserGetDifferentUserJobJson < Minitest::Test
def test_user_fail_get_different_user_job
assert_equal 404, @getcode
assert_equal 'Not found', @getbody['error']
assert_equal 'not found', @getbody['error']
end
end
......@@ -243,7 +243,7 @@ class TestUserDelDifferentUserJobJson < Minitest::Test
def test_user_fail_del_different_user_job
assert_equal 404, @getcode
assert_equal 'Not found', @getbody['error']
assert_equal 'not found', @getbody['error']
end
end
......@@ -263,7 +263,7 @@ class TestUserUpdateDifferentUserJobJson < Minitest::Test
def test_user_fail_update_different_user_job
assert_equal 404, @putcode
assert_equal 'Not found', @putbody['error']
assert_equal 'not found', @putbody['error']
end
end
......@@ -282,6 +282,6 @@ class TestUserPatchDifferentUserJobJson < Minitest::Test
def test_user_fail_patch_different_user_job
assert_equal 404, @patchcode
assert_equal 'Not found', @patchbody['error']
assert_equal 'not found', @patchbody['error']
end
end
......@@ -187,7 +187,7 @@ class TestGetJobIdNotFoundXml < Minitest::Test
def test_id_not_found
assert_equal 404, @code
assert_equal ['Not found'], @body['error']
assert_equal ['not found'], @body['error']
end
end
......@@ -225,7 +225,7 @@ class TestUserGetDifferentUserJobXml < Minitest::Test
def test_user_fail_get_different_user_job
assert_equal 404, @getcode
assert_equal ['Not found'], @getbody['error']
assert_equal ['not found'], @getbody['error']
end
end
......@@ -243,7 +243,7 @@ class TestUserDelDifferentUserJobXml < Minitest::Test
def test_user_fail_del_different_user_job
assert_equal 404, @getcode
assert_equal ['Not found'], @getbody['error']
assert_equal ['not found'], @getbody['error']
end
end
......@@ -263,7 +263,7 @@ class TestUserUpdateDifferentUserJobXml < Minitest::Test
def test_user_fail_update_different_user_job
assert_equal 404, @putcode
assert_equal ['Not found'], @putbody['error']
assert_equal ['not found'], @putbody['error']
end
end
......@@ -282,6 +282,6 @@ class TestUserPatchDifferentUserJobXml < Minitest::Test
def test_user_fail_patch_different_user_job
assert_equal 404, @patchcode
assert_equal ['Not found'], @patchbody['error']
assert_equal ['not found'], @patchbody['error']
end
end
......@@ -9,7 +9,7 @@ class TestGetRootPathJson < Minitest::Test
def test_root_not_found
assert_equal 404, @code
assert_equal 'application/json', @headers['content-type'][0]
assert_equal 'Not found', @body['error']
assert_equal 'not found', @body['error']
end
end
......@@ -21,7 +21,7 @@ class TestGetNotMatchingPathJson < Minitest::Test
def test_root_not_found
assert_equal 404, @code
assert_equal 'application/json', @headers['content-type'][0]
assert_equal 'Not found', @body['error']
assert_equal 'not found', @body['error']
end
end
......@@ -45,7 +45,7 @@ class TestBadAuthJson < Minitest::Test
def test_unauthorized
assert_equal 401, @code
assert_equal 'application/json', @headers['content-type'][0]
assert_equal 'Unauthorized', @body['error']
assert_equal 'unauthorized', @body['error']
end
end
......@@ -57,6 +57,6 @@ class TestBadKeyJson < Minitest::Test
def test_unauthorized_key
assert_equal 401, @code
assert_equal 'application/json', @headers['content-type'][0]
assert_equal 'Unauthorized', @body['error']
assert_equal 'unauthorized', @body['error']
end
end
......@@ -9,7 +9,7 @@ class TestGetRootPathXml < Minitest::Test
def test_root_not_found
assert_equal 404, @code
assert_equal 'application/xml', @headers['content-type'][0]
assert_equal ['Not found'], @body['error']
assert_equal ['not found'], @body['error']
end
end
......@@ -21,7 +21,7 @@ class TestGetNotMatchingPathXml < Minitest::Test
def test_root_not_found
assert_equal 404, @code
assert_equal 'application/xml', @headers['content-type'][0]
assert_equal ['Not found'], @body['error']
assert_equal ['not found'], @body['error']
end
end
......@@ -45,7 +45,7 @@ class TestBadAuthXml < Minitest::Test
def test_unauthorized
assert_equal 401, @code
assert_equal 'application/xml', @headers['content-type'][0]
assert_equal ['Unauthorized'], @body['error']
assert_equal ['unauthorized'], @body['error']
end
end
......@@ -57,6 +57,6 @@ class TestBadKeyXml < Minitest::Test
def test_unauthorized_key
assert_equal 401, @code
assert_equal 'application/xml', @headers['content-type'][0]
assert_equal ['Unauthorized'], @body['error']
assert_equal ['unauthorized'], @body['error']
end
end
......@@ -56,7 +56,7 @@ class TestGetUnknownIdJson < Minitest::Test
def test_type_unknown
assert_equal 404, @code
assert_equal 'Not found', @body['error']
assert_equal 'not found', @body['error']
end
end
......@@ -67,6 +67,6 @@ class TestDeleteUserTypeJson < Minitest::Test
def test_type_unknown
assert_equal 405, @code
assert_equal 'Method not allowed', @body['error']
assert_equal 'method not allowed', @body['error']
end
end
......@@ -56,7 +56,7 @@ class TestGetUnknownIdXml < Minitest::Test
def test_type_unknown
assert_equal 404, @code
assert_equal ['Not found'], @body['error']
assert_equal ['not found'], @body['error']
end
end
......@@ -67,6 +67,6 @@ class TestDeleteUserTypeXml < Minitest::Test
def test_type_unknown
assert_equal 405, @code
assert_equal ['Method not allowed'], @body['error']
assert_equal ['method not allowed'], @body['error']
end
end
......@@ -56,7 +56,7 @@ class TestCreateUserMissingFieldsJson < Minitest::Test
def test_missing_email
assert_equal 400, @code
assert_equal 'Required field missing: email', @body['error']
assert_equal 'required field missing: email', @body['error']
end
end
......@@ -188,7 +188,7 @@ class TestGetUserIdNotFoundJson < Minitest::Test
def test_id_not_found
assert_equal 404, @code
assert_equal 'Not found', @body['error']
assert_equal 'not found', @body['error']
end
end
......@@ -204,7 +204,7 @@ class TestUserCreateUserJson < Minitest::Test
def test_user_forbidden
assert_equal 403, @usercode
assert_equal 'Forbidden', @userbody['error']
assert_equal 'forbidden', @userbody['error']
end
end
......@@ -235,7 +235,7 @@ class TestUserDelUserJson < Minitest::Test
def test_user_fail_del_self
assert_equal 403, @delcode
assert_equal 'Forbidden', @delbody['error']
assert_equal 'forbidden', @delbody['error']
end
end
......@@ -253,7 +253,7 @@ class TestUserGetDifferentUserJson < Minitest::Test
def test_user_fail_get_different_user
assert_equal 404, @getcode
assert_equal 'Not found', @getbody['error']
assert_equal 'not found', @getbody['error']
end
end
......@@ -273,7 +273,7 @@ class TestUserUpdateDifferentUserJson < Minitest::Test
def test_user_fail_update_different_user
assert_equal 404, @putcode
assert_equal 'Not found', @putbody['error']
assert_equal 'not found', @putbody['error']
end
end
......@@ -292,7 +292,7 @@ class TestUserPatchDifferentUserJson < Minitest::Test
def test_user_fail_patch_different_user
assert_equal 404, @patchcode
assert_equal 'Not found', @patchbody['error']
assert_equal 'not found', @patchbody['error']
end
end
......@@ -382,7 +382,7 @@ class TestUserCreateDisabledUserAndAuthJson < Minitest::Test
def test_create_disabled_user_and_auth
assert_equal 401, @authcode
assert_equal 'application/json', @authheaders['content-type'][0]
assert_equal 'Unauthorized', @authbody['error']
assert_equal 'unauthorized', @authbody['error']
end
end
......@@ -400,7 +400,7 @@ class TestUserCreateDeletedUserAndAuthJson < Minitest::Test
def test_create_deleted_user_and_auth
assert_equal 401, @authcode
assert_equal 'application/json', @authheaders['content-type'][0]
assert_equal 'Unauthorized', @authbody['error']
assert_equal 'unauthorized', @authbody['error']
end
end
......@@ -425,7 +425,7 @@ class TestUserGetUsersThenDisableJson < Minitest::Test
assert_equal 401, @discode
assert_equal 'application/json', @disheaders['content-type'][0]
assert_equal 'Unauthorized', @disbody['error']
assert_equal 'unauthorized', @disbody['error']
end
end
......@@ -450,6 +450,6 @@ class TestUserGetUsersThenDeleteJson < Minitest::Test
assert_equal 401, @discode
assert_equal 'application/json', @disheaders['content-type'][0]
assert_equal 'Unauthorized', @disbody['error']
assert_equal 'unauthorized', @disbody['error']
end
end
......@@ -56,7 +56,7 @@ class TestCreateUserMissingFieldsXml < Minitest::Test
def test_missing_email
assert_equal 400, @code
assert_equal ['Required field missing: email'], @body['error']
assert_equal ['required field missing: email'], @body['error']
end
end
......@@ -188,7 +188,7 @@ class TestGetUserIdNotFoundXml < Minitest::Test
def test_id_not_found
assert_equal 404, @code
assert_equal ['Not found'], @body['error']
assert_equal ['not found'], @body['error']
end
end
......@@ -204,7 +204,7 @@ class TestUserCreateUserXml < Minitest::Test
def test_user_forbidden
assert_equal 403, @usercode
assert_equal ['Forbidden'], @userbody['error']
assert_equal ['forbidden'], @userbody['error']
end
end
......@@ -235,7 +235,7 @@ class TestUserDelUserXml < Minitest::Test
def test_user_fail_del_self
assert_equal 403, @delcode
assert_equal ['Forbidden'], @delbody['error']
assert_equal ['forbidden'], @delbody['error']
end
end
......@@ -253,7 +253,7 @@ class TestUserGetDifferentUserXml < Minitest::Test
def test_user_fail_get_different_user
assert_equal 404, @getcode
assert_equal ['Not found'], @getbody['error']
assert_equal ['not found'], @getbody['error']
end
end
......@@ -273,7 +273,7 @@ class TestUserUpdateDifferentUserXml < Minitest::Test
def test_user_fail_update_different_user
assert_equal 404, @putcode
assert_equal ['Not found'], @putbody['error']
assert_equal ['not found'], @putbody['error']
end
end
......@@ -292,7 +292,7 @@ class TestUserPatchDifferentUserXml < Minitest::Test
def test_user_fail_patch_different_user
assert_equal 404, @patchcode
assert_equal ['Not found'], @patchbody['error']
assert_equal ['not found'], @patchbody['error']
end
end
......@@ -368,13 +368,13 @@ class TestUserChangeUserTypePatchXml < Minitest::Test
end
end
class TestUserCreateDisabledUserAndAuthJson < Minitest::Test
class TestUserCreateDisabledUserAndAuthXml < Minitest::Test
def setup
@user_payl = default_user_xml
@code, @headers, @body = payl_request_xml(:post, '/users', ADMIN_KEY_JSON, @user_payl, 'user')
@code, @headers, @body = payl_request_xml(:post, '/users', ADMIN_KEY_XML, @user_payl, 'user')
@user_patch = { :status => ['disabled'] }
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@body['user'][0]['id'][0]}", ADMIN_KEY_JSON, @user_patch, 'user')
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@body['user'][0]['id'][0]}", ADMIN_KEY_XML, @user_patch, 'user')
@authcode, @authheaders, @authbody = auth_request_xml(@user_payl[:login][0], @user_payl[:password][0])
end
......@@ -382,17 +382,17 @@ class TestUserCreateDisabledUserAndAuthJson < Minitest::Test
def test_create_disabled_user_and_auth
assert_equal 401, @authcode
assert_equal 'application/xml', @authheaders['content-type'][0]
assert_equal ['Unauthorized'], @authbody['error']
assert_equal ['unauthorized'], @authbody['error']
end
end
class TestUserCreateDeletedUserAndAuthJson < Minitest::Test
class TestUserCreateDeletedUserAndAuthXml < Minitest::Test
def setup
@user_payl = default_user_xml
@code, @headers, @body = payl_request_xml(:post, '/users', ADMIN_KEY_JSON, @user_payl, 'user')
@code, @headers, @body = payl_request_xml(:post, '/users', ADMIN_KEY_XML, @user_payl, 'user')
@user_patch = { :status => ['deleted'] }
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@body['user'][0]['id'][0]}", ADMIN_KEY_JSON, @user_patch, 'user')
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@body['user'][0]['id'][0]}", ADMIN_KEY_XML, @user_patch, 'user')
@authcode, @authheaders, @authbody = auth_request_xml(@user_payl[:login][0], @user_payl[:password][0])
end
......@@ -400,20 +400,20 @@ class TestUserCreateDeletedUserAndAuthJson < Minitest::Test
def test_create_deleted_user_and_auth
assert_equal 401, @authcode
assert_equal 'application/xml', @authheaders['content-type'][0]
assert_equal ['Unauthorized'], @authbody['error']
assert_equal ['unauthorized'], @authbody['error']
end
end
class TestUserGetUsersThenDisableJson < Minitest::Test
class TestUserGetUsersThenDisableXml < Minitest::Test
def setup
@user_payl = default_user_xml
@postcode, @postheaders, @postbody = payl_request_xml(:post, '/users', ADMIN_KEY_JSON, @user_payl, 'user')
@postcode, @postheaders, @postbody = payl_request_xml(:post, '/users', ADMIN_KEY_XML, @user_payl, 'user')
user_key, user_id = user_key_id_xml(@user_payl[:login][0], @user_payl[:password][0])
@getcode, @getheaders, @getbody = get_request_xml('/users', user_key)
@user_patch = { :status => ['disabled'] }
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@postbody['user'][0]['id'][0]}", ADMIN_KEY_JSON, @user_patch, 'user')
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@postbody['user'][0]['id'][0]}", ADMIN_KEY_XML, @user_patch, 'user')
@discode, @disheaders, @disbody = get_request_xml('/users', user_key)
end
......@@ -425,20 +425,20 @@ class TestUserGetUsersThenDisableJson < Minitest::Test
assert_equal 401, @discode
assert_equal 'application/xml', @disheaders['content-type'][0]
assert_equal ['Unauthorized'], @disbody['error']
assert_equal ['unauthorized'], @disbody['error']
end
end
class TestUserGetUsersThenDeleteJson < Minitest::Test
class TestUserGetUsersThenDeleteXml < Minitest::Test
def setup
@user_payl = default_user_xml
@postcode, @postheaders, @postbody = payl_request_xml(:post, '/users', ADMIN_KEY_JSON, @user_payl, 'user')
@postcode, @postheaders, @postbody = payl_request_xml(:post, '/users', ADMIN_KEY_XML, @user_payl, 'user')
user_key, user_id = user_key_id_xml(@user_payl[:login][0], @user_payl[:password][0])
@getcode, @getheaders, @getbody = get_request_xml('/users', user_key)
@user_patch = { :status => ['deleted'] }
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@postbody['user'][0]['id'][0]}", ADMIN_KEY_JSON, @user_patch, 'user')
@patchcode, @patchheaders, @patchbody = payl_request_xml(:patch, "/users/#{@postbody['user'][0]['id'][0]}", ADMIN_KEY_XML, @user_patch, 'user')