"""
Ensure that modules that have conflicting commands do not get imported.
It should also display a readable error message indicating where the conflicting
command was found.
"""

import seash_dictionary
import seash_modules
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)

#pragma out Module cannot be imported due to the following conflicting command:
#pragma out show (default)

import seash
seash.command_loop([
  'enable conflict'
])
Esempio n. 2
0
"""
Test that the geoip module functions correctly.

"""
import os
import seash
import sys

# We need the modules module
import seash_modules
import seash_dictionary
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

commands = [
    'enable geoip', 'disable geoip', 'enable geoip', 'loadkeys guest0',
    'as guest0', 'browse', 'on %1', 'show location', 'show coordinates'
]

# Allow the geoip module to be disabled when done,
# even if exceptions occur
try:
    seash.command_loop(commands)
except Exception, e:
    print >> sys.stderr, str(e)

# Make sure the geoip module is disabled after this run.
# This is to ensure that other modules' tests are not affected by this module.
seash.command_loop(['disable geoip'])
Esempio n. 3
0
"""
Make sure that preprocessed command line input is printed to the screen
"""

import sys

import seash_dictionary

#pragma out Enabled modules:
import seash

import seash_modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

# There shouldn't be any output from here on...
# If the file has anything inside it after we're done, then it is an error.
sys.stdout = open('test_results.txt', 'w')

seash.command_loop([
    'enable variables', 'set showparse off', 'set username guest0',
    'loadkeys $username', 'as $username$', 'disable variables'
])

sys.stdout.close()
sys.stdout = sys.__stdout__

test_output = open('test_results.txt', 'r').read()
if test_output:
    print test_output
Esempio n. 4
0
"""
Ensure that all modules do not conflict with each other

"""
#pragma out
import os
import seash

import seash_dictionary
import seash_modules
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

commands = [
    # Enable all the modules
    'enable geoip',
    'enable factoids',
    'enable variables',
    # Disable all the modules
    'disable geoip',
    'disable factoids',
    'disable variables',
]

seash.command_loop(commands)
Esempio n. 5
0
"""
Joins two nodes owned by guest0 and splits them again using resources.offcut
to test if the two commands work properly on the basic scale.
"""
#pragma out
import seash
import sys

command_list = [
    'loadkeys guest3', 'as guest3', 'browse', 'on browsegood', 'update',
    'join', 'on %3', 'split resources.offcut'
]

seash.command_loop(command_list)
Esempio n. 6
0
import sys

# We need the modules module
import seash_modules
import seash_dictionary
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)


commands = [
  'enable geoip',
  'disable geoip',
  'enable geoip',
  'loadkeys guest0',
  'as guest0',
  'browse',
  'on %1',
  'show location',
  'show coordinates'
]

# Allow the geoip module to be disabled when done, 
# even if exceptions occur
try:
  seash.command_loop(commands)
except Exception, e:
  print>>sys.stderr, str(e)

# Make sure the geoip module is disabled after this run.
# This is to ensure that other modules' tests are not affected by this module.
seash.command_loop(['disable geoip'])
Esempio n. 7
0
    seash_dictionary.seashcommanddict)

# Prevent printing to console by using test_results.txt as a text dump and redirecting output there
orig_stdout = sys.stdout
sys.stdout = open("test_results.txt", "w")

os.mkdir('test_dir')
os.mkdir('test_dir' + os.path.sep + 'test_subdir')

command_list = [
    'loadkeys guest0', 'as guest0', 'browse', 'on browsegood', 'show modules',
    'enable uploaddir', 'disable uploaddir', 'enable uploaddir',
    'savestate testing_state'
]

seash.command_loop(command_list)

sys.stdout.close()

#pragma out Skipping sub-directory 'test_subdir'. You may upload it separately.

# Resets stdout to allow printing to console to allow UTF to catch errors printed by seash
sys.stdout = orig_stdout

command_list = [
    'loadkeys guest0',
    'as guest0',
    'loadstate testing_state',
    'uploaddir test_dir',
]
"""

import sys

import seash_dictionary

#pragma out Enabled modules:
import seash

import seash_modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)

# There shouldn't be any output from here on...
# If the file has anything inside it after we're done, then it is an error.
sys.stdout = open('test_results.txt', 'w')

seash.command_loop([
  'enable variables',
  'set showparse off',
  'set username guest0',
  'loadkeys $username',
  'as $username$',
  'disable variables'])

sys.stdout.close()
sys.stdout = sys.__stdout__

test_output = open('test_results.txt', 'r').read()
if test_output:
  print test_output
  
Esempio n. 9
0
"""
Ensure that modules that have conflicting commands do not get imported.
It should also display a readable error message indicating where the conflicting
command was found.
"""

import seash_dictionary
import seash_modules
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

#pragma out Module cannot be imported due to the following conflicting command:
#pragma out show (default)

import seash
seash.command_loop(['enable conflict'])
"""
Make sure that disabling a disabled module fails
"""
import seash
import seash_exceptions

# We need to do module manipulation
import seash_dictionary
import seash_modules
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)

seash.command_loop(["enable geoip"])

# This should fail.  We can't use the built in UTF pragma because we need to 
# disable the module before we finish this test.
try:
  seash.command_loop(["enable geoip"])
except seash_exceptions.UserError, e:
  if "Module is already enabled." not in str(e):
    raise

seash.command_loop(["disable geoip"])
Esempio n. 11
0
"""
Makes sure the Variables module for seash works as intended.
In particular, we check that the $varname and $varname$ methods of referencing
variables are functional.
"""

import seash

import seash_dictionary
import seash_modules

#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

seash.command_loop([
    'enable variables',
    'set helpcmd help',
    '$helpcmd',
    '$helpcmd show',
    '$helpcmd$',
    '$helpcmd$ show',
    'disable variables',
])
Esempio n. 12
0
"""
Test commands that manipulate the modules within seash

"""
import sys
import seash
import seash_dictionary
import seash_modules

#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

oldstdout = sys.stdout
sys.stdout = open('test_results.txt', 'w')

seash.command_loop([
    'show modules',
    'enable geoip',
    'show modules',
    'modulehelp geoip',
    'disable geoip',
])

sys.stdout = oldstdout
expected_lines = open('modulemanipulation_test_results.txt', 'r').readlines()
actual_lines = open('test_results.txt', 'r').readlines()

for lineno in xrange(len(actual_lines)):
    if expected_lines[lineno] != actual_lines[lineno]:
        print "Line", lineno, "of test results are not consistent with expected results: modulemanipulation_test_results.txt"
Test commands that manipulate the modules within seash

"""
import sys
import seash
import seash_dictionary
import seash_modules

#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)


oldstdout = sys.stdout
sys.stdout = open('test_results.txt', 'w')


seash.command_loop([
  'show modules',
  'enable geoip',
  'show modules',
  'modulehelp geoip',
  'disable geoip',
])

sys.stdout = oldstdout
expected_lines = open('modulemanipulation_test_results.txt', 'r').readlines()
actual_lines = open('test_results.txt', 'r').readlines()

for lineno in xrange(len(actual_lines)):
  if expected_lines[lineno] != actual_lines[lineno]:
    print "Line", lineno, "of test results are not consistent with expected results: modulemanipulation_test_results.txt"
# We need the modules module
import seash_modules
import seash_dictionary
#pragma out Added group 'acquired' with 5 targets
#pragma out acquired (empty)

seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

commands = [
    'enable clearinghouse',
    'loadkeys seash_gettest',
    'as seash_gettest',
    'get insecure 5',
    'on acquired',
    'release insecure acquired',
    'show targets',
]

# Allow the geoip module to be disabled when done,
# even if exceptions occur
try:
    seash.command_loop(commands)
except Exception, e:
    print >> sys.stderr, str(e)

# Make sure the geoip module is disabled after this run.
# This is to ensure that other modules' tests are not affected by this module.
seash.command_loop(['disable clearinghouse'])
"""
Makes sure the Variables module for seash works as intended.
In particular, we check that trailing delimiters are not recognized as a
variable.
"""
import seash
import seash_dictionary
import seash_exceptions
import seash_modules

#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)


# This error should come up since %all contains nothing as we don't browse for
# anything prior to this.  This is not a problem though as we are just testing
# the trailing $ in a command.
try:
  seash.command_loop([
    'enable variables',
    'add %all to $',
  ])
except seash_exceptions.UserError, e:
  if not "No targets to add (the target is already in '$'" in str(e):
    raise

seash.command_loop(['disable variables'])
Esempio n. 16
0
"""
Ensure that all modules do not conflict with each other

"""
#pragma out
import os
import seash

import seash_dictionary
import seash_modules
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)


commands = [
  # Enable all the modules
  'enable geoip',
  'enable factoids',
  'enable variables',
  # Disable all the modules
  'disable geoip',
  'disable factoids',
  'disable variables',
  ]

seash.command_loop(commands)
Esempio n. 17
0
os.mkdir('test_dir')
os.mkdir('test_dir' + os.path.sep + 'test_subdir')

command_list = [
  'loadkeys guest0', 
  'as guest0', 
  'browse', 
  'on browsegood',
  'show modules',
  'enable uploaddir',
  'disable uploaddir',
  'enable uploaddir',
  'savestate testing_state'
  ]

seash.command_loop(command_list)

sys.stdout.close()

#pragma out Skipping sub-directory 'test_subdir'. You may upload it separately.

# Resets stdout to allow printing to console to allow UTF to catch errors printed by seash
sys.stdout = orig_stdout

command_list = [
  'loadkeys guest0', 
  'as guest0', 
  'loadstate testing_state',
  'uploaddir test_dir', 
]
Esempio n. 18
0
import sys

# We need the modules module
import seash_modules
import seash_dictionary
#pragma out Added group 'acquired' with 5 targets
#pragma out acquired (empty)

seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)

commands = [
  'enable clearinghouse',
  'loadkeys seash_gettest',
  'as seash_gettest',
  'get 5',
  'on acquired',
  'release acquired',
  'show targets',
]

# Allow the geoip module to be disabled when done,
# even if exceptions occur
try:
  seash.command_loop(commands)
except Exception, e:
  print>>sys.stderr, str(e)

# Make sure the geoip module is disabled after this run.
# This is to ensure that other modules' tests are not affected by this module.
seash.command_loop(['disable clearinghouse'])
"""
Makes sure the Variables module for seash works as intended.
In particular, we check that the $varname and $varname$ methods of referencing
variables are functional.
"""

import seash

import seash_dictionary
import seash_modules

#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(seash_dictionary.seashcommanddict)

seash.command_loop([
  'enable variables',
  'set helpcmd help',
  '$helpcmd',
  '$helpcmd show',
  '$helpcmd$',
  '$helpcmd$ show',
  'disable variables',
])
orig_stdout = sys.stdout

# To temporarily prevent printing to console, test_results.txt is used as a text
# dump as stdout is redirected to it
sys.stdout = open("test_results.txt", "w")

command_list = [
  'loadkeys guest0', 
  'as guest0', 
  'browse', 
  'on %1', 
  'savestate testing_state'
  ] 

seash.command_loop(command_list)

sys.stdout.close()



# No output or errors should be thrown in the following series of commands
sys.stdout = orig_stdout

command_list = [
  'loadkeys guest0', 
  'as guest0', 
  'loadstate testing_state', 
  'add to test_group', 
  'remove %1 from test_group', 
  'add %1 to test_group_2',
"""
Make sure that disabling a disabled module fails
"""
import seash
import seash_exceptions

# We need to do module manipulation
import seash_dictionary
import seash_modules
#pragma out Enabled modules: modules
seash_modules.enable_modules_from_last_session(
    seash_dictionary.seashcommanddict)

seash.command_loop(["enable geoip"])

# This should fail.  We can't use the built in UTF pragma because we need to
# disable the module before we finish this test.
try:
    seash.command_loop(["enable geoip"])
except seash_exceptions.UserError, e:
    if "Module is already enabled." not in str(e):
        raise

seash.command_loop(["disable geoip"])