Exemplo n.º 1
0
class TestOrganizationFactory(unittest.TestCase):

    def setUp(self):
        self._factory = OrganizationFactory(uuid1(), ANY, transport=MagicMock())

    def test_make_directory_client(self):
        self.assertIsInstance(self._factory.make_directory_client(uuid1()), DirectoryClient)

    def test_make_organization_client(self):
        self.assertIsInstance(self._factory.make_organization_client(), OrganizationClient)

    def test_make_service_client(self):
        self.assertIsInstance(self._factory.make_service_client(uuid1()), ServiceClient)
Exemplo n.º 2
0
def main(ctx, entity_type, entity_id, private_key, api):
    """
    ENTITY_TYPE: Entity type for the given ID. This can be a Service,
    Directory, or Organization.

    ENTITY_ID: Entity ID in the form of a UUID for the given Service,
    Directory, or Organization.

    PRIVATE_KEY: Path to private key belonging to the given entity ID.
    IE: /path/to/my.key
    """

    # ensure that ctx.obj exists and is a dict (in case `cli()` is called
    # by means other than the `if` block below
    ctx.ensure_object(dict)

    entity_type = entity_type.lower()
    private_key = private_key.read()
    if entity_type == "organization":
        ctx.obj['factory'] = OrganizationFactory(entity_id, private_key,
                                                 url=api)
    elif entity_type == "directory":
        ctx.obj['factory'] = DirectoryFactory(entity_id, private_key, url=api)
    elif entity_type == "service":
        ctx.obj['factory'] = ServiceFactory(entity_id, private_key, url=api)
    else:
        raise TypeError("Input entity type is not valid. Should be one of: "
                        "Organization, Directory, Service.")
Exemplo n.º 3
0
class TestOrganizationFactory(unittest.TestCase):
    def setUp(self):
        self._factory = OrganizationFactory(uuid1(),
                                            ANY,
                                            transport=MagicMock())

    def test_make_directory_client(self):
        self.assertIsInstance(self._factory.make_directory_client(uuid1()),
                              DirectoryClient)

    def test_make_organization_client(self):
        self.assertIsInstance(self._factory.make_organization_client(),
                              OrganizationClient)

    def test_make_service_client(self):
        self.assertIsInstance(self._factory.make_service_client(uuid1()),
                              ServiceClient)
    def __init__(self, organization_id, organization_key, directory_id,
                 service_id, launchkey_url, use_advanced_webhooks):
        self.organization_id = organization_id
        self.directory_id = directory_id
        self.service_id = service_id

        organization_factory = OrganizationFactory(organization_id,
                                                   organization_key,
                                                   url=launchkey_url)
        self.organization_client = organization_factory.\
            make_organization_client()
        self.directory_client = organization_factory.make_directory_client(
            directory_id)
        self.service_client = organization_factory.make_service_client(
            service_id)

        self.use_advanced_webhooks = use_advanced_webhooks
Exemplo n.º 5
0
def before_all(context):
    context.organization_factory = OrganizationFactory(
        context.organization_id,
        context.organization_private_key,
        url=getattr(context, 'launchkey_url', LAUNCHKEY_PRODUCTION))
    sample_app_package = 'com.launchkey.android.authenticator.demo.javaApp'

    desired_caps = dict()
    # Increase the default idle time in order to prevent the session from
    # closing while non device tests are being ran.
    desired_caps['newCommandTimeout'] = 600
    desired_caps['appPackage'] = sample_app_package
    desired_caps[
        'appWaitActivity'] = 'com.launchkey.android.authenticator.demo.' \
                             'ui.activity.ListDemoActivity'
    desired_caps['fullReset'] = True
    desired_caps['noReset'] = False
    desired_caps['captureScreenshots'] = True
    desired_caps['disableWindowAnimation'] = True

    if hasattr(context, 'appium_url'):
        desired_caps['platformName'] = context.platform_name
        desired_caps['platformVersion'] = context.platform_version
        desired_caps['automationName'] = 'UiAutomator2'
        desired_caps['deviceName'] = context.device_name
        desired_caps['app'] = context.sample_app_apk_path
        context.appium_device_manager = AppiumDeviceManager(context.appium_url,
                                                            desired_caps,
                                                            sample_app_package,
                                                            timeout_period=10)
    elif hasattr(context, 'kobiton_username') and hasattr(
            context, 'kobiton_sdk_key'):
        context.kobiton_manager = KobitonManager(context.kobiton_username,
                                                 context.kobiton_sdk_key)
        context.uploaded_app = context.kobiton_manager.upload_app(
            context.sample_app_apk_path)

        devices = context.kobiton_manager.get_devices()
        for device in devices:
            # Look for a device that is not currently booked (check out by
            # another user), is online and ready to use, is Android (currently
            # the only supported device type), and a platform that is greater
            # than 5.0
            if not device.is_booked and device.is_online and device.platform_name == "Android" and \
                    int(device.platform_version[0]) > 5:
                desired_caps['platformName'] = device.platform_name
                desired_caps['platformVersion'] = device.platform_version
                desired_caps['automationName'] = 'UiAutomator2'
                desired_caps['deviceName'] = device.device_name
                desired_caps['app'] = "kobiton-store:v%s" % \
                                      context.uploaded_app.versions[0].id

                context.appium_device_manager = AppiumDeviceManager(
                    'https://%s:%[email protected]/wd/hub' %
                    (context.kobiton_username, context.kobiton_sdk_key),
                    desired_caps,
                    sample_app_package,
                    timeout_period=10)
                break
        if 'deviceName' not in desired_caps:
            raise Exception(
                "No viable device found in Kobiton. Note that you need "
                "an available Android device with an OS > v5.0.0")

    if hasattr(context, 'appium_device_manager'):
        context.sample_app_device_manager = SampleAppDeviceManager(
            context.appium_device_manager)
Exemplo n.º 6
0
 def setUp(self):
     self._factory = OrganizationFactory(uuid1(),
                                         ANY,
                                         transport=MagicMock())
Exemplo n.º 7
0
app = Flask(__name__)
bootstrap = Bootstrap(app)
app.debug = True
app.config['SECRET_KEY'] = "Welcometolaunchkey"
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://///Users/ianhinden/Documents/Programming/LaunchKeyTest/LaunchKeyTest/database.db'
db = SQLAlchemy(app)

organization_id = "9eb44784-ffb6-11e7-beac-32c85991b6e3"
organization_private_key = open('organization_private_key.key').read()
directory_id = "8d8bc0e2-015d-11e8-9daa-16cd5ddd3780"
service_id = "df4d2d1a-ffb6-11e7-a5f3-4697f50c1dd9"
service_private_key = open('service_private_key.key').read()

service_factory = ServiceFactory(service_id, service_private_key)
organization_factory = OrganizationFactory(organization_id, organization_private_key)
directory_client = organization_factory.make_directory_client(directory_id)
service_client = organization_factory.make_service_client(service_id)

class User(db.Model):
	id = db.Column(db.Integer, primary_key=True)
	username = db.Column(db.String(), unique=True)
	email = db.Column(db.String(), unique=True)
	password = db.Column(db.String())
	phone = db.Column(db.String(), unique=True)


class LoginForm(FlaskForm):
	username = StringField("username", validators=[InputRequired(), Length(min=4, max=15)])
	#password = PasswordField("password", validators=[InputRequired(), Length(min=8)])
	submit = SubmitField('Sign In')
Exemplo n.º 8
0
 def setUp(self):
     self._factory = OrganizationFactory(uuid1(), ANY, transport=MagicMock())