Created
January 27, 2016 01:54
-
-
Save DavidBiesack/6ce2025cbd6f4bbd028c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name" : "default environment", | |
"env" : { | |
"assignee" : "sasdjb", | |
"creator" : "sasdjb", | |
"who" : "{user.name}", | |
"commenter" : "resttest", | |
"host" : "jiradev.sas.com", | |
"jiraUri" : "https://{host}/rest/api/2", | |
"issue" : "RESTTEST-1" | |
} | |
}, | |
{ | |
"name" : "jira.template", | |
"doc" : [ "This template specifies the authentication and other defaults for JIRA API calls.", | |
"JIRA REST API requires basic auth. Credentials are in the .netrc file in the form:", | |
" machine jiradev.sas.com login jirauserid password jirasecret" | |
], | |
"auth" : { "basic" : true } | |
}, | |
{ | |
"name" : "Get JIRA ticket details", | |
"doc" : [ "Get the details for JIRA issue RESTTEST-1 . ", | |
"This requires valid credentials in the .netrc file in the form:", | |
"machine jiradev.sas.com login jirauserid password jirasecret" | |
], | |
"template" : "jira.template", | |
"GET" : "{jiraUri}/issue/{issue}?fields=creator,assignee", | |
"bind" : { "json" : "response" }, | |
"assert" : [ | |
"response != null", | |
"response.key.textValue() == issue", | |
{ "doc" : [ "Unfortunately I can't use Groovy to access response.fields because Jackson's ObjectNode", | |
"class defines a method called getFields so Groovy accesses that instead of looking up", | |
"a JSON field named 'fields'. So instead, use .get('fields')" ] }, | |
"response.get('fields').creator.name.textValue() == creator", | |
"response.get('fields').assignee.name.textValue() == assignee" | |
] | |
}, | |
{ | |
"name" : "Add comment to existing ticket", | |
"env" : { "comment" : "This is the text of a comment posted via UnRAVL by user {who}" }, | |
"template" : "jira.template", | |
"POST" : "{jiraUri}/issue/{issue}/comment", | |
"headers" : { "Content-Type" : "application/json" }, | |
"body" : { "json" : { "body" : "{comment}" } }, | |
"bind" : { "headers" : { "location" : "Location" } } | |
}, | |
{ | |
"name" : "Check that the comment exists", | |
"template" : "jira.template", | |
"HEAD" : "{location}" | |
}, | |
{ | |
"name" : "Get the comment, echo it to stdout", | |
"template" : "jira.template", | |
"GET" : "{location}", | |
"headers" : { "Accept" : "application/json" }, | |
"bind" : { "json" : "originalComment" , | |
"text" : "@-" }, | |
"assert" : [ | |
"originalComment.body.textValue() == comment", | |
"originalComment.author.name.textValue() == commenter" | |
] | |
}, | |
{ | |
"name" : "Update the comment", | |
"env" : { "newComment" : "This is the updated content of the new comment, updated by user {who}" }, | |
"template" : "jira.template", | |
"PUT" : "{location}", | |
"headers" : { "Content-Type" : "application/json" }, | |
"body" : { "json" : { "body" : "{newComment}" } } | |
}, | |
{ | |
"name" : "Get the comment, echo it to stdout", | |
"template" : "jira.template", | |
"GET" : "{location}", | |
"headers" : { "Accept" : "application/json" }, | |
"bind" : { "json" : "response" }, | |
"assert" : "response.body.textValue() == newComment" | |
}, | |
{ | |
"name" : "Delete the new comment", | |
"template" : "jira.template", | |
"DELETE" : "{location}" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment