Changeset - fe69cbd7a13f
[Not reviewed]
0 6 0
Jan Kaluza - 9 years ago 2016-03-06 20:13:52
jkaluza@redhat.com
Web interface: support diplaying tables generated on transport's side
6 files changed with 111 insertions and 28 deletions:
0 comments (0 inline, 0 general)
include/transport/AdminInterfaceCommand.h
Show inline comments
 
@@ -51,30 +51,31 @@ class AdminInterfaceCommand {
 

	
 
		typedef enum {
 
			General,
 
			Users,
 
			Messages,
 
			Frontend,
 
			Backends,
 
			Memory
 
		} Category;
 

	
 
		class Arg {
 
			public:
 
				Arg(const std::string &_name, const std::string &_label, const std::string &_example) :
 
					name(_name), label(_label), example(_example) {}
 
				Arg(const std::string &_name, const std::string &_label, const std::string &_type, const std::string &_example) :
 
					name(_name), label(_label), type(_type), example(_example) {}
 
				~Arg() {}
 

	
 
				std::string name;
 
				std::string label;
 
				std::string type;
 
				std::string example;
 
		};
 

	
 
		AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions, const std::string &label = "");
 

	
 
		virtual ~AdminInterfaceCommand() { }
 

	
 
		void setDescription(const std::string &desc) {
 
			m_desc = desc;
 
		}
 

	
 
		const std::string &getDescription() {
 
@@ -94,26 +95,26 @@ class AdminInterfaceCommand {
 
		}
 

	
 
		const std::string getCategoryName(Category category);
 

	
 
		Context getContext() {
 
			return m_context;
 
		}
 

	
 
		AccessMode getAccessMode() {
 
			return m_accessMode;
 
		}
 

	
 
		void addArg(const std::string &name, const std::string &label, const std::string &example = "") {
 
			Arg arg(name, label, example);
 
		void addArg(const std::string &name, const std::string &label, const std::string &type = "string", const std::string &example = "") {
 
			Arg arg(name, label, type, example);
 
			m_args.push_back(arg);
 
		}
 

	
 
		const std::list<Arg> &getArgs() {
 
			return m_args;
 
		}
 

	
 
		const std::string &getLabel() {
 
			return m_label;
 
		}
 

	
 
		virtual std::string handleSetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
libtransport/AdminInterface.cpp
Show inline comments
 
@@ -103,42 +103,43 @@ class UptimeCommand : public AdminInterfaceCommand {
 

	
 
	private:
 
		time_t m_start;
 
};
 

	
 
class OnlineUsersCommand : public AdminInterfaceCommand {
 
	public:
 
		
 
		OnlineUsersCommand(UserManager *userManager) : AdminInterfaceCommand("online_users",
 
							AdminInterfaceCommand::Users,
 
							AdminInterfaceCommand::GlobalContext,
 
							AdminInterfaceCommand::AdminMode,
 
							AdminInterfaceCommand::Get) {
 
							AdminInterfaceCommand::Execute,
 
							"Online users") {
 
			m_userManager = userManager;
 
			setDescription("Returns list of all online users");
 
		}
 

	
 
		virtual std::string handleGetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleGetRequest(uinfo, user, args);
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, user, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			const std::map<std::string, User *> &users = m_userManager->getUsers();
 
			if (users.empty()) {
 
				ret = "0";
 
				ret = "hanzz@njs.netlab.cz \"3rd-party network username:\" \"me\"\n";
 
			}
 

	
 
			for (std::map<std::string, User *>::const_iterator it = users.begin(); it != users.end(); it ++) {
 
				ret += (*it).first + "\n";
 
				ret += (*it).first + " \"3rd-party network username:\" \"" + user->getUserInfo().uin + "\"\n";
 
			}
 
			return ret;
 
		}
 

	
 
	private:
 
		UserManager *m_userManager;
 
};
 

	
 
class OnlineUsersCountCommand : public AdminInterfaceCommand {
 
	public:
 
		
 
		OnlineUsersCountCommand(UserManager *userManager) : AdminInterfaceCommand("online_users_count",
 
@@ -273,25 +274,25 @@ class ReloadCommand : public AdminInterfaceCommand {
 
};
 

	
 
class HasOnlineUserCommand : public AdminInterfaceCommand {
 
	public:
 
		
 
		HasOnlineUserCommand(UserManager *userManager) : AdminInterfaceCommand("has_online_user",
 
							AdminInterfaceCommand::Users,
 
							AdminInterfaceCommand::GlobalContext,
 
							AdminInterfaceCommand::AdminMode,
 
							AdminInterfaceCommand::Execute, "Has online user") {
 
			m_userManager = userManager;
 
			setDescription("Returns 1 if user is online");
 
			addArg("username", "Username", "user@domain.tld");
 
			addArg("username", "Username", "string", "user@domain.tld");
 
		}
 

	
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, user, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			if (args.empty()) {
 
				return "Error: Missing user name as an argument";
 
			}
 

	
 
@@ -708,25 +709,25 @@ class RegisterCommand : public AdminInterfaceCommand {
 
							"Register") {
 
			m_userRegistration = userRegistration;
 
			setDescription("Registers the new user");
 

	
 
			std::string fields = component->getFrontend()->getRegistrationFields();
 
			std::vector<std::string> args;
 
			boost::split(args, fields, boost::is_any_of("\n"));
 
			addArg("username", args[0]);
 
			if (fields.size() > 1) {
 
				addArg("legacy_username", args[1]);
 
			}
 
			if (fields.size() > 2) {
 
				addArg("legacy_password", args[2]);
 
				addArg("legacy_password", args[2], "password");
 
			}
 
		}
 

	
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, user, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			if (args.size() != 2 && args.size() != 3) {
 
				return "Error: Bad argument count";
 
			}
 
@@ -835,25 +836,25 @@ class GetOAuth2URLCommand : public AdminInterfaceCommand {
 
							AdminInterfaceCommand::AdminMode,
 
							AdminInterfaceCommand::Execute) {
 
			m_component = component;
 
			setDescription("get_oauth2_code - Get OAUth2 URL");
 
			std::string fields = component->getFrontend()->getRegistrationFields();
 
			std::vector<std::string> args;
 
			boost::split(args, fields, boost::is_any_of("\n"));
 
			addArg("username", args[0]);
 
			if (fields.size() > 1) {
 
				addArg("legacy_username", args[1]);
 
			}
 
			if (fields.size() > 2) {
 
				addArg("legacy_password", args[2]);
 
				addArg("legacy_password", args[2], "password");
 
			}
 
		}
 

	
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, user, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			std::string url = m_component->getFrontend()->getOAuth2URL(args);
 
			return url;
 
		}
 
@@ -1042,76 +1043,76 @@ class VariablesCommand : public AdminInterfaceCommand {
 
};
 

	
 
class ArgsCommand : public AdminInterfaceCommand {
 
	public:
 
		
 
		ArgsCommand(std::map<std::string, AdminInterfaceCommand *> *commands) : AdminInterfaceCommand("args",
 
							AdminInterfaceCommand::General,
 
							AdminInterfaceCommand::GlobalContext,
 
							AdminInterfaceCommand::AdminMode,
 
							AdminInterfaceCommand::Execute, "Command's arguments") {
 
			m_commands = commands;
 
			setDescription("Shows descripton of arguments for command");
 
			addArg("command", "Command", "register");
 
			addArg("command", "Command", "string", "register");
 
		}
 

	
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, user, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			std::map<std::string, AdminInterfaceCommand *>::iterator it = m_commands->find(args[0]);
 
			if (it == m_commands->end()) {
 
				return "Error: Unknown command passed as an argument.";
 
			}
 
			AdminInterfaceCommand *command = it->second;
 

	
 
			BOOST_FOREACH(const AdminInterfaceCommand::Arg &arg, command->getArgs()) {
 
				ret += arg.name + " - \"" + arg.label + "\" " + "Example: \"" + arg.example + "\"\n";
 
				ret += arg.name + " - \"" + arg.label + "\" " + "Example: \"" + arg.example + "\" Type: \"" + arg.type + "\"\n";
 
			}
 

	
 
			return ret;
 
		}
 

	
 
	private:
 
		std::map<std::string, AdminInterfaceCommand *> *m_commands;
 
};
 

	
 

	
 
AdminInterface::AdminInterface(Component *component, UserManager *userManager, NetworkPluginServer *server, StorageBackend *storageBackend, UserRegistration *userRegistration) {
 
	m_component = component;
 
	m_storageBackend = storageBackend;
 
	m_userManager = userManager;
 
	m_server = server;
 
	m_userRegistration = userRegistration;
 

	
 
	m_component->getFrontend()->onMessageReceived.connect(bind(&AdminInterface::handleMessageReceived, this, _1));
 

	
 
	addCommand(new StatusCommand(m_server, m_userManager));
 
	addCommand(new UptimeCommand());
 
	addCommand(new OnlineUsersCommand(m_userManager));
 
	addCommand(new OnlineUsersCountCommand(m_userManager));
 
	addCommand(new ReloadCommand(m_component));
 
	addCommand(new OnlineUsersPerBackendCommand(m_server));
 
// 	addCommand(new OnlineUsersPerBackendCommand(m_server));
 
	addCommand(new HasOnlineUserCommand(m_userManager));
 
	addCommand(new BackendsCountCommand(m_server));
 
	addCommand(new ResMemoryCommand(m_server));
 
	addCommand(new ShrMemoryCommand(m_server));
 
	addCommand(new UsedMemoryCommand(m_server));
 
	addCommand(new AverageMemoryPerUserCommand(m_server, m_userManager));
 
	addCommand(new ResMemoryPerBackendCommand(m_server));
 
	addCommand(new ShrMemoryPerBackendCommand(m_server));
 
	addCommand(new UsedMemoryPerBackendCommand(m_server));
 
	addCommand(new AverageMemoryPerUserPerBackendCommand(m_server));
 
// 	addCommand(new ResMemoryPerBackendCommand(m_server));
 
// 	addCommand(new ShrMemoryPerBackendCommand(m_server));
 
// 	addCommand(new UsedMemoryPerBackendCommand(m_server));
 
// 	addCommand(new AverageMemoryPerUserPerBackendCommand(m_server));
 
	addCommand(new CrashedBackendsCountCommand(m_server));
 
	addCommand(new CrashedBackendsCommand(m_server));
 
	addCommand(new MessagesFromXMPPCommand(m_userManager));
 
	addCommand(new MessagesToXMPPCommand(m_userManager));
 
	addCommand(new SetOAuth2CodeCommand(m_component));
 
	addCommand(new GetOAuth2URLCommand(m_component));
 
	addCommand(new HelpCommand(&m_commands));
 
	addCommand(new ArgsCommand(&m_commands));
 
	addCommand(new CommandsCommand(&m_commands));
 
	addCommand(new VariablesCommand(&m_commands));
 

	
 
	if (m_userRegistration) {
spectrum/src/frontends/slack/SlackUserManager.cpp
Show inline comments
 
@@ -90,30 +90,32 @@ class JoinRoomCommand : public AdminInterfaceCommand {
 
			std::string legacyRoomLabel = CONFIG_STRING_DEFAULTED(cfg, "service.join_room_room_label", "3rd-party room name");
 
			if (legacyRoomLabel[0] == '%') {
 
				legacyRoomLabel[0] = '#';
 
			}
 

	
 
			std::string legacyRoomExample = CONFIG_STRING_DEFAULTED(cfg, "service.join_room_room_example", "3rd-party room name");
 
			if (legacyRoomExample[0] == '%') {
 
				legacyRoomExample[0] = '#';
 
			}
 

	
 
			addArg("nickname",
 
				   CONFIG_STRING_DEFAULTED(cfg, "service.join_room_nickname_label", "Nickname in 3rd-party room"),
 
				   "string",
 
				   CONFIG_STRING_DEFAULTED(cfg, "service.join_room_nickname_example", "BotNickname"));
 
			addArg("legacy_room", legacyRoomLabel, legacyRoomExample);
 
			addArg("legacy_room", legacyRoomLabel, "string", legacyRoomExample);
 
			addArg("legacy_server",
 
				   CONFIG_STRING_DEFAULTED(cfg, "service.join_room_server_label", "3rd-party server"),
 
				   "string",
 
				   CONFIG_STRING_DEFAULTED(cfg, "service.join_room_server_example", "3rd.party.server.org"));
 
			addArg("slack_channel", "Slack Chanel", "mychannel");
 
			addArg("slack_channel", "Slack Chanel", "string", "mychannel");
 
		}
 

	
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *u, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, u, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			if (uinfo.id == -1) {
 
				return "Error: Unknown user";
 
			}
 

	
 
@@ -138,25 +140,25 @@ class JoinRoomCommand : public AdminInterfaceCommand {
 
class LeaveRoomCommand : public AdminInterfaceCommand {
 
	public:
 
		
 
		LeaveRoomCommand(StorageBackend *storageBackend) : AdminInterfaceCommand("leave_room",
 
							AdminInterfaceCommand::Frontend,
 
							AdminInterfaceCommand::UserContext,
 
							AdminInterfaceCommand::UserMode,
 
							AdminInterfaceCommand::Execute,
 
							"Leave 3rd-party network room") {
 
			m_storageBackend = storageBackend;
 
			setDescription("Leave the room");
 

	
 
			addArg("slack_channel", "Slack Chanel", "mychannel");
 
			addArg("slack_channel", "Slack Chanel", "string", "mychannel");
 
		}
 

	
 
		virtual std::string handleExecuteRequest(UserInfo &uinfo, User *u, std::vector<std::string> &args) {
 
			std::string ret = AdminInterfaceCommand::handleExecuteRequest(uinfo, u, args);
 
			if (!ret.empty()) {
 
				return ret;
 
			}
 

	
 
			if (uinfo.id == -1) {
 
				return "Error: Unknown user";
 
			}
 

	
spectrum_manager/src/APIServer.cpp
Show inline comments
 
@@ -476,35 +476,36 @@ void APIServer::serve_instances_command_args(Server *server, Server::session *se
 
		argList.PushBack(arg, json.GetAllocator());
 
	}
 

	
 
	BOOST_FOREACH(const std::string &argument, args) {
 
		escaped_list_separator<char> els('\\', ' ', '\"');
 
		tokenizer<escaped_list_separator<char> > tok(argument, els);
 

	
 
		std::vector<std::string> tokens;
 
		for(tokenizer<escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end(); ++beg) {
 
			tokens.push_back(*beg);
 
		}
 

	
 
		if (tokens.size() != 5) {
 
		if (tokens.size() != 7) {
 
			continue;
 
		}
 

	
 
		tmp.push_back(tokens);
 

	
 
		Value arg;
 
		arg.SetObject();
 
		arg.AddMember("name", tokens[0].c_str(), json.GetAllocator());
 
		arg.AddMember("label", tokens[2].c_str(), json.GetAllocator());
 
		arg.AddMember("example", tokens[4].c_str(), json.GetAllocator());
 
		arg.AddMember("type", tokens[6].c_str(), json.GetAllocator());
 
		argList.PushBack(arg, json.GetAllocator());
 
	}
 

	
 
	json.AddMember("args", argList, json.GetAllocator());
 
	send_json(conn, json);
 
}
 

	
 

	
 
void APIServer::serve_instances_execute(Server *server, Server::session *session, struct mg_connection *conn, struct http_message *hm) {
 
	std::string uri(hm->uri.p, hm->uri.len);
 
	std::string instance = uri.substr(uri.rfind("/") + 1);
 
	std::string command = get_http_var(hm, "command");
 
@@ -565,29 +566,82 @@ void APIServer::serve_instances_execute(Server *server, Server::session *session
 

	
 
		command += " " + username;
 
	}
 

	
 
	for (int i = 0; i < 10; ++i) {
 
		std::string var = get_http_var(hm, std::string(std::string("command_arg") + boost::lexical_cast<std::string>(i)).c_str());
 
		if (!var.empty()) {
 
			command += " " + var;
 
		}
 
	}
 

	
 
	response = server->send_command(instance, command);
 
	boost::replace_all(response, "\n", "<br/>");
 
	if (response.find("Error:") == 0) {
 
		send_ack(conn, false, response);
 
	}
 

	
 
	std::vector<std::string> fields;
 
	boost::split(fields, response, boost::is_any_of("\n"));
 
	if (!fields.empty() && /*fields[0].find(" - ") != std::string::npos &&*/ (fields[0].find(": ") != std::string::npos || fields[0].find(":\"") != std::string::npos)) {
 
		Document json;
 
		json.SetObject();
 
		json.AddMember("error", 0, json.GetAllocator());
 

	
 
		std::vector<std::string> tmp;
 
		std::vector<std::string> tmp2;
 
		Value table(kArrayType);
 

	
 
		BOOST_FOREACH(const std::string &line, fields) {
 
			escaped_list_separator<char> els('\\', ' ', '\"');
 
			tokenizer<escaped_list_separator<char> > tok(line, els);
 

	
 
			Value arg;
 
			arg.SetObject();
 

	
 
			std::string key;
 
			int i = 0;
 
			bool hasDesc = true;
 
			for(tokenizer<escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end(); ++beg, ++i) {
 
				if (i == 1 && *beg != "-") {
 
					hasDesc = false;
 
				}
 
				if (i == 0) {
 
					tmp.push_back(*beg);
 
					arg.AddMember("Key", tmp.back().c_str(), json.GetAllocator());
 
				}
 
				else if (i == 2 && hasDesc) {
 
					tmp.push_back(*beg);
 
					arg.AddMember("Description", tmp.back().c_str(), json.GetAllocator());
 
				}
 
				else if (i > 1 || (!hasDesc && i > 0)) {
 
					if (key.empty()) {
 
						key = *beg;
 
					}
 
					else {
 
						tmp.push_back(key);
 
						tmp2.push_back(*beg);
 
						arg.AddMember(tmp.back().c_str(), tmp2.back().c_str(), json.GetAllocator());
 
						key = "";
 
					}
 
				}
 
			}
 
			table.PushBack(arg, json.GetAllocator());
 
		}
 

	
 
		json.AddMember("table", table, json.GetAllocator());
 
		json.AddMember("message", response.c_str(), json.GetAllocator());
 
		send_json(conn, json);
 
	}
 
	else {
 
		boost::replace_all(response, "\n", "<br/>");
 
		send_ack(conn, true, response);
 
	}
 
}
 

	
 
void APIServer::serve_users(Server *server, Server::session *session, struct mg_connection *conn, struct http_message *hm) {
 
	ALLOW_ONLY_ADMIN();
 

	
 
	Document json;
 
	json.SetObject();
 
	json.AddMember("error", 0, json.GetAllocator());
 

	
 
	std::vector<std::string> list;
spectrum_manager/src/html/js/app.js
Show inline comments
 
@@ -126,25 +126,30 @@ function fill_users_register_form() {
 
}
 

	
 
function execute_command(instance, command) {
 
	$.get($.cookie("base_location") +  'api/v1/instances/command_args/' + instance + '?command=' + command, function(data) {
 
		var form = '<div class="row">';
 

	
 
		if (data.args.length != 0) {
 
			form += '<div class="col-md-12"><form class="form-horizontal">';
 
			$.each(data.args, function(i, arg) {
 
				form += '<div class="form-group">';
 
				form += '<label class="col-md-4 control-label" for="' + arg.name + '">' + arg.label + ':</label>';
 
				form += '<div class="col-md-4">';
 
				if (arg.type == "password") {
 
					form += '<input id="command_arg' + i + '" name="command_arg' + i + '" type="password" placeholder="' + arg.example + '" class="form-control input-md"/>';
 
				}
 
				else {
 
					form += '<input id="command_arg' + i + '" name="command_arg' + i + '" type="text" placeholder="' + arg.example + '" class="form-control input-md"/>';
 
				}
 
				form += '</div></div>';
 
				console.log('command_arg' + i );
 
			});
 
		}
 
		else {
 
			form += '<div><form class="form-horizontal">';
 
			form += '<div class="form-group">';
 
			form += '<label class="control-label">No arguments needed for this command, you can just execute it.</label>';
 
			form += '</div>';
 
		}
 

	
 
		form += '</form></div></div>'
 
@@ -202,24 +207,44 @@ function execute_command(instance, command) {
 
							}
 
							else {
 
								var posturl = $.cookie("base_location") + "api/v1/instances/execute/" + instance + "?command=" + command;
 
							}
 
							var postdata = {}
 
							for (i = 0; i < 10; i++) {
 
								var val = $('#command_arg' + i).val();
 
								if (val) {
 
									postdata["command_arg" + i] = val;
 
								}
 
							}
 
							$.post(posturl, postdata, function(data) {
 
								if (data.table) {
 
									data.message = "<table>";
 
									data.message += "<tr>";
 
									for (var key in data.table[0]) {
 
										if (data.table[0].hasOwnProperty(key)) {
 
											data.message += "<th>" + key + "</th>";
 
										}
 
									}
 
									data.message += "</tr>";
 
									$.each(data.table, function(i, line) {
 
										data.message += "<tr>";
 
										for (var key in line) {
 
											if (line.hasOwnProperty(key)) {
 
												data.message += "<td>" + line[key] + "</td>";
 
											}
 
										}
 
										data.message += "</tr>";
 
									})
 
									data.message += "</table>";
 
								}
 
								var dialog = bootbox.dialog({
 
									title: "Command result: " + command + ".",
 
									message: "<pre>" + data.message + "</pre>",
 
									buttons: {
 
										success: {
 
											label: "OK",
 
											className: "btn-success",
 
											callback: function () {
 
												if (command == "unregister") {
 
													location.reload(); 
 
												}
 
											}
tests/libtransport/AdminInterface.cpp
Show inline comments
 
@@ -60,28 +60,28 @@ class AdminInterfaceTest : public CPPUNIT_NS :: TestFixture, public BasicSlackTe
 
	void helpCommand() {
 
		std::string resp = sendAdminMessage("help");
 
		CPPUNIT_ASSERT(resp.find("   VAR   status - Shows instance status\n") != std::string::npos);
 
	}
 

	
 
	void statusCommand() {
 
		std::string resp = sendAdminMessage("status");
 
		CPPUNIT_ASSERT_EQUAL(std::string("Running (0 users connected using 0 backends)"), resp);
 
	}
 

	
 
	void joinRoomArgs() {
 
		std::string resp = sendAdminMessage("args join_room");
 
		CPPUNIT_ASSERT_EQUAL(std::string("nickname - \"Nickname in 3rd-party room\" Example: \"BotNickname\"\n"
 
							"legacy_room - \"3rd-party room name\" Example: \"3rd-party room name\"\n"
 
							"legacy_server - \"3rd-party server\" Example: \"3rd.party.server.org\"\n"
 
							"slack_channel - \"Slack Chanel\" Example: \"mychannel\"\n"), resp);
 
		CPPUNIT_ASSERT_EQUAL(std::string("nickname - \"Nickname in 3rd-party room\" Example: \"BotNickname\" Type: \"string\"\n"
 
							"legacy_room - \"3rd-party room name\" Example: \"3rd-party room name\" Type: \"string\"\n"
 
							"legacy_server - \"3rd-party server\" Example: \"3rd.party.server.org\" Type: \"string\"\n"
 
							"slack_channel - \"Slack Chanel\" Example: \"mychannel\" Type: \"string\"\n"), resp);
 
	}
 

	
 
	void getOAuth2URLCommand() {
 
		std::string resp = sendAdminMessage("get_oauth2_url x y z");
 
		CPPUNIT_ASSERT(resp.find("https://slack.com/oauth/authorize?client_id=&scope=channels%3Aread%20channels%3Awrite%20team%3Aread%20im%3Aread%20im%3Awrite%20chat%3Awrite%3Abot%20bot&redirect_uri=https%3A%2F%2Fslack.spectrum.im%2Foauth2%2Flocalhost&state=") != std::string::npos);
 
	}
 

	
 
	void unknownCommand() {
 
		std::string resp = sendAdminMessage("unknown_command test");
 
		CPPUNIT_ASSERT_EQUAL(std::string("Error: Unknown variable or command"), resp);
 
	}
 

	
0 comments (0 inline, 0 general)