- add isMeetingRunning test
This commit is contained in:
parent
6f9563b190
commit
e3ef2e5f6f
@ -269,21 +269,41 @@ class ApiController {
|
||||
def isMeetingRunning = {
|
||||
log.debug CONTROLLER_NAME + "#isMeetingRunning"
|
||||
|
||||
if (!doChecksumSecurity("isMeetingRunning")) {
|
||||
invalidChecksum(); return;
|
||||
// Do we have a checksum? If none, complain.
|
||||
if (StringUtils.isEmpty(params.checksum)) {
|
||||
invalid("missingParamChecksum", "You must pass a checksum and query string.");
|
||||
return
|
||||
}
|
||||
|
||||
String mtgID = params.meetingID
|
||||
// Do we have a meeting id? If none, complain.
|
||||
String externalMeetingId = params.meetingID
|
||||
if (StringUtils.isEmpty(externalMeetingId)) {
|
||||
invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
|
||||
return
|
||||
}
|
||||
|
||||
Meeting conf = dynamicConferenceService.getConferenceByMeetingID(mtgID);
|
||||
boolean isRunning = conf != null && conf.isRunning();
|
||||
// Do we agree on the checksum? If not, complain.
|
||||
if (! dynamicConferenceService.isChecksumSame("join", params.checksum, request.getQueryString())) {
|
||||
invalidChecksum(); return;
|
||||
}
|
||||
|
||||
// Everything is good so far. Translate the external meeting id to an internal meeting id. If
|
||||
// we can't find the meeting, complain.
|
||||
String internalMeetingId = dynamicConferenceService.getInternalMeetingId(externalMeetingId);
|
||||
log.info("Retrieving meeting ${internalMeetingId}")
|
||||
Meeting meeting = dynamicConferenceService.getMeeting(internalMeetingId);
|
||||
if (meeting == null) {
|
||||
invalid("invalidMeetingIdentifier", "The meeting ID that you supplied did not match any existing meetings");
|
||||
return;
|
||||
}
|
||||
|
||||
response.addHeader("Cache-Control", "no-cache")
|
||||
withFormat {
|
||||
xml {
|
||||
render(contentType:"text/xml") {
|
||||
response() {
|
||||
returncode(RESP_CODE_SUCCESS)
|
||||
running(isRunning ? "true" : "false")
|
||||
running(meeting.isRunning() ? "true" : "false")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Meeting {
|
||||
public boolean isRunning() {
|
||||
// boolean running = startTime != null && endTime == null;
|
||||
//println "running: ${running}; startTime: ${startTime}; endTime: ${endTime}";
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -54,14 +54,34 @@ class ApiControllerTests extends ControllerUnitTestCase {
|
||||
void testJoinAPI() {
|
||||
|
||||
/** Create the meeting to set things up */
|
||||
|
||||
|
||||
ApiController controller = new ApiController()
|
||||
mockLogging(ApiController)
|
||||
controller.setDynamicConferenceService(service)
|
||||
createConference(controller)
|
||||
controller.create();
|
||||
println "controller response = " + controller.response.contentAsString
|
||||
|
||||
/**
|
||||
* Now that the meeting has been setup. Try to join it.
|
||||
*/
|
||||
ApiController controller2 = new ApiController()
|
||||
mockLogging(ApiController)
|
||||
controller2.setDynamicConferenceService(service)
|
||||
joinConference(controller2)
|
||||
controller2.join()
|
||||
|
||||
/**
|
||||
* Need to use controller2.redirectArgs['url'] instead of controller2.response.redirectedUrl as
|
||||
* shown in the grails doc because it is returning null for me.
|
||||
*
|
||||
* see http://kousenit.wordpress.com/2010/11/10/unit-testing-grails-controllers-revisited/
|
||||
*/
|
||||
assertEquals CLIENT_URL, controller2.redirectArgs['url']
|
||||
}
|
||||
|
||||
private void joinConference(ApiController controller) {
|
||||
String username = "Richard"
|
||||
String modPass = "testm"
|
||||
|
||||
@ -74,22 +94,8 @@ class ApiControllerTests extends ControllerUnitTestCase {
|
||||
mockParams.password = MOD_PASS
|
||||
mockParams.checksum = checksum
|
||||
mockRequest.queryString = queryString
|
||||
|
||||
ApiController controller2 = new ApiController()
|
||||
mockLogging(ApiController)
|
||||
controller2.setDynamicConferenceService(service)
|
||||
controller2.join()
|
||||
|
||||
/**
|
||||
* Need to use controller2.redirectArgs['url'] instead of controller2.response.redirectedUrl as
|
||||
* shown in the grails doc because it is returning null for me.
|
||||
*
|
||||
* see http://kousenit.wordpress.com/2010/11/10/unit-testing-grails-controllers-revisited/
|
||||
*/
|
||||
assertEquals CLIENT_URL, controller2.redirectArgs['url']
|
||||
}
|
||||
|
||||
|
||||
private void createConference(ApiController controller) {
|
||||
String queryString = "meetingID=${MEETING_ID}&name=${MEETING_NAME}&moderatorPW=${MOD_PASS}&attendeePW=${VIEW_PASS}"
|
||||
String checksum = DigestUtils.shaHex("create" + queryString + SALT)
|
||||
@ -100,6 +106,6 @@ class ApiControllerTests extends ControllerUnitTestCase {
|
||||
mockParams.name = MEETING_NAME
|
||||
mockParams.moderatorPW = MOD_PASS
|
||||
mockParams.attendeePW = VIEW_PASS
|
||||
mockRequest.queryString = queryString
|
||||
mockRequest.queryString = queryString
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user