Ejemplo n.º 1
0
	def test_commands_displayed(self):
		with self.client:
			self.client.post(
				'/login',
				data=dict(username="******", password="******"),
				follow_redirects=True
			)
			db.session.add(Command(
				"s",
				"http://www.google.com/search?q=%s",
				"Google Search",
				getGroupId("global"),
				getUserId("ghooo")
			))
			db.session.add(Command(
				"p",
				"http://pastie.org/",
				"Pastie",
				getUserId("ghooo"),
				getUserId("ghooo")
			))
			db.session.commit()
			response = self.client.get(
				'/dashboard'
			)
			self.assertIn(b'Global Commands', response.data)
			self.assertIn(b'User Commands', response.data)
			self.assertIn(b'Google Search', response.data)
Ejemplo n.º 2
0
	def test_access_own_global_commands_only(self):
		db.session.add(Command( \
				"s", \
				"http://www.google.com/search?q=%s", \
				"Google Search", \
				getUserId("ghooo"), \
				getUserId("ghooo") \
				))
		db.session.add(Command( \
				"p", \
				"http://pastie.org", \
				"Pastie", \
				getUserId("omarayad1"), \
				getUserId("omarayad1") \
				))
		db.session.add(Command( \
				"t", \
				"https://translate.google.com/#en/ar/%s", \
				"Google Translate", \
				getGroupId("global"), \
				getUserId("omarayad1") \
				))
		with self.client:
			self.client.post(
				'/login',
				data=dict(username="******", password="******"),
				follow_redirects=True
			)

			# access global commands
			response = self.client.get(
				'/?q=t awesome'
			)
			self.assertIn(b'<a href="https://translate.google.com/#en/ar/'
					'awesome">https://translate.google.com/#en/ar/awesome</a>', 
					response.data)

			# access own commands
			response = self.client.get(
				'/?q=s awesome'
			)
			self.assertIn(b'<a href="http://www.google.com/search?q=awesome">'
					'http://www.google.com/search?q=awesome</a>', 
					response.data)

			# can not access other users commands
			response = self.client.get(
				'/?q=p'
			)
			self.assertIn(b'<a href="http://www.google.com/search?q=p">'
					'http://www.google.com/search?q=p</a>', 
					response.data)
Ejemplo n.º 3
0
	def test_commands_priority(self):
		db.session.add(Command( \
				"s", \
				"http://www.google.com/search?q=%s", \
				"Google Search", \
				getGroupId("global"), \
				getUserId("omarayad1") \
				))

		with self.client:
			self.client.post(
				'/login',
				data=dict(username="******", password="******"),
				follow_redirects=True
			)

			# access to global command
			response = self.client.get(
				'/?q=s awesome'
			)
			self.assertIn(b'<a href="http://www.google.com/search?q=awesome">'
					'http://www.google.com/search?q=awesome</a>', 
					response.data)

			# creating another command with the same cmd_id
			db.session.add(Command( \
					"s", \
					"http://www.bing.com/search?q=%s", \
					"Bing Search", \
					getUserId("ghooo"), \
					getUserId("ghooo") \
					))

			# should get the user command
			response = self.client.get(
				'/?q=s awesome'
			)
			self.assertIn(b'<a href="http://www.bing.com/search?q=awesome">'
					'http://www.bing.com/search?q=awesome</a>', 
					response.data)
Ejemplo n.º 4
0
	def test_with_cmd_id_empty_queryText(self):
		db.session.add(Command( \
				"s", \
				"http://www.google.com/search?q=%s", \
				"Google Search", \
				getGroupId("global"), \
				getUserId("ghooo") \
				))
		db.session.commit()
		response = self.client.get('/?q=s', 
				content_type='html/text')
		self.assertIn(b'<a href="http://www.google.com/search?q=">'
				'http://www.google.com/search?q=</a>', response.data)
Ejemplo n.º 5
0
db.session.add(Group("global", "Global Group"))

## users
db.session.add(User("ghooo", "Mohamed", "Ghoneim", "ghooo", \
		"*****@*****.**"))
db.session.add(User("omarayad1", "Omar", "Ayad", "omarayad1", \
		"*****@*****.**"))

## commands
### global commands
db.session.add(Command( \
		"s", \
		"http://www.google.com/search?q=%s", \
		"Google Search", \
		getGroupId("global"), \
		getUserId("ghooo") \
		))

db.session.add(Command( \
		"g", \
		"http://www.google.com/search?q=%s", \
		"Google Search", \
		getGroupId("global"), \
		getUserId("ghooo") \
		))

db.session.add(Command( \
		"t", \
		"https://translate.google.com/#en/ar/%s", \
		"Google Translate", \
		getGroupId("global"), \