Beispiel #1
0
def test_env_override():
    assert str(env(merge_env=False)) == s('USH_VAR1=var1\nUSH_VAR2=var2\n')
    assert str(env(merge_env=False, env={})) == ''
    assert str(
        env(merge_env=False, env={
            'USH_VAR3': 'var3',
            'USH_VAR4': 'var4'
        })) == s('USH_VAR3=var3\nUSH_VAR4=var4\n')
Beispiel #2
0
def login():
    query = """
        mutation {
            login(input: {username: \"%s\", password: \"%s\"}) {token}
        }
    """ % (env('username'), env('password'))

    print query

    respond(requests.post(env('url'), json={'query': query}, headers=headers),
            inspect.currentframe().f_code.co_name)
Beispiel #3
0
def updateUser():
    userInput = {
        'firstName': 'sbs',
        'lastName': 'sbs',
        'password': '******',
        'phoneNumber': '+9779841044832',
    }

    query = """
        mutation {
            updateUser(input: {
                firstName: \"%s\",
                lastName: \"%s\",
                password: \"%s\",
                phoneNumber: \"%s\",
                photo: \"\",
                fbId: \"\"
            }) {
                status
                token
                User { email firstName }
            }
        }
    """ % (userInput['firstName'], userInput['lastName'],
           userInput['password'], userInput['phoneNumber'])

    print query

    respond(userInput,
            requests.post(env('url'), json={'query': query}, headers=headers),
            inspect.currentframe().f_code.co_name)
Beispiel #4
0
def test_bad_secret():
    with env(COMMITTEE_CONFIG=config_env):
        app = _test_app()
        rv = app.post('/', json=PING, headers={
            'X-Hub-Signature': 'sha1=1cacacc4207bdd4a51a7528bd9a5b9d6546b0c22',
            'X-GitHub-Event': 'ping'})
        assert rv.status_code >= 400
Beispiel #5
0
def test_ping_pong():
    with env(COMMITTEE_CONFIG=config_env):
        app = _test_app()
        rv = app.post('/', json=PING, headers={
            'X-Hub-Signature': 'sha1=578851772a72bb7f96001fb28d7217642e344d3b',
            'X-GitHub-Event': 'ping'})
        assert rv.status_code == 200
Beispiel #6
0
def createTrip():
    tripInput = {
        'description': 'Trip create test',
        'type': 'wanted',
        'tripStart':
        '{ name: "Kathmandu", countryCode: "NP", coordinates:[20.0,20.0] }',
        'tripEnd':
        '{ name: \"Pokhara\", countryCode:\"NP\", coordinates:[10.0,20.0] }',
        'stops':
        '[{name: \"Mugling\", countryCode: \"NP\", coordinates: [11.0,12.0]}]',
        'returnTrip': 'true',
        'dates': '[\"2017-02-11\",\"2017-10-11\"]',
        'time': '02:00',
        'flexibility': '15min',
        'seats': '10'
    }

    query = """
        mutation {
            createTrip(input: {
            description: \"%s\",
            type: %s,
            TripStart: %s,
            TripEnd: %s,
            Stops: %s,
            returnTrip: %s,
            dates: %s,
            time:\"%s\",
            flexibility: \"%s\",
            seats: %s })
            {
                description,
                type,
                TripStart { name countryCode }
                TripEnd { name countryCode }
                Stops { name countryCode }
                returnTrip
                date
                time
                flexibility
                seats
                User { email }
            }
        }
    """ % (tripInput['description'], tripInput['type'], tripInput['tripStart'],
           tripInput['tripEnd'], tripInput['stops'], tripInput['returnTrip'],
           tripInput['dates'], tripInput['time'], tripInput['flexibility'],
           tripInput['seats'])

    print query

    respond(tripInput,
            requests.post(env('url'), json={'query': query}, headers=headers),
            inspect.currentframe().f_code.co_name)
Beispiel #7
0
def test_ping_pongs():
    with env(FILABEL_CONFIG=config_env):
        app = _test_app()
        rv = app.post('/',
                      json=PING,
                      headers={
                          'X-Hub-Signature':
                          'sha1=7528bd9a5b9d6546b0c221cacacc4207bdd4a51a',
                          'X-GitHub-Event': 'ping'
                      })
        assert rv.status_code == 200
Beispiel #8
0
def group():
    groupInput = {
        'outreach': 'route',
        'tripStart':
        '{ name: "Kathmandu", countryCode: "NP", coordinates:[20.0,20.0] }',
        'tripEnd':
        '{ name: \"Pokhara\", countryCode:\"NP\", coordinates:[10.0,20.0] }',
        'stops':
        '[{name: \"Mugling\", countryCode: \"NP\", coordinates: [11.0,12.0]}]',
        'countryCode': 'NP',
        'name': 'Test Group',
        'description': 'This is a Test Group',
        'type': 'OpenGroup',
    }

    query = """
        mutation {
            group(input: {
                outreach: %s,
                TripStart: %s,
                TripEnd: %s,
                Stops: %s,
                countryCode: \"%s\",
                name: \"%s\",
                description: \"%s\",
                type: %s
            }) {
                name
                description
                User { id email }
                country
                stopsIds
                Stops { name countryCode coordinates }
                type
                outreach
            }
        }
    """ % (
        groupInput['outreach'],
        groupInput['tripStart'],
        groupInput['tripEnd'],
        groupInput['stops'],
        groupInput['countryCode'],
        groupInput['name'],
        groupInput['description'],
        groupInput['type'],
    )

    print query

    respond(groupInput,
            requests.post(env('url'), json={'query': query}, headers=headers),
            inspect.currentframe().f_code.co_name)
Beispiel #9
0
def test_app_get_has_rules():
    with env(COMMITTEE_CONFIG=config_env):
        app = _test_app()
        text = app.get('/').get_data(as_text=True)
        assert 'no-shits' in text
        assert 'There is something shitty.' in text
        assert 'persist-readme' in text
        assert 'README is important, do not delete it.' in text
        assert 'relatively-forbidden' in text
        assert 'There are some relatively forbidden words in the message.' in text
        assert 'many-changes' in text
        assert 'Too many changes in the file.' in text
Beispiel #10
0
def test_unset_env():
    assert str(env(env={'USH_VAR1': None})) == s('USH_VAR2=var2\n')
    assert str(env(env={'USH_VAR1': None, 'USH_VAR2': None})) == ''
Beispiel #11
0
def test_new_env_merged_by_default():
    assert str(env(env={
        'USH_VAR3': 'var3',
        'USH_VAR4': 'var4'
    })) == s('USH_VAR1=var1\nUSH_VAR2=var2\nUSH_VAR3=var3\nUSH_VAR4=var4\n')
Beispiel #12
0
import os, sys, inspect, requests

sys.path.append(os.getcwd() + '/util/')
from helper import respond, env

headers = {'Content-Type': 'application/json', 'Authorization': env('token')}


def updateUser():
    userInput = {
        'firstName': 'sbs',
        'lastName': 'sbs',
        'password': '******',
        'phoneNumber': '+9779841044832',
    }

    query = """
        mutation {
            updateUser(input: {
                firstName: \"%s\",
                lastName: \"%s\",
                password: \"%s\",
                phoneNumber: \"%s\",
                photo: \"\",
                fbId: \"\"
            }) {
                status
                token
                User { email firstName }
            }
        }
Beispiel #13
0
def test_dangerous_ping_pong():
    with env(COMMITTEE_CONFIG=config_env_nosecret):
        app = _test_app()
        rv = app.post('/', json=PING, headers={'X-GitHub-Event': 'ping'})
        assert rv.status_code == 200
Beispiel #14
0
def test_app_get_has_username():
    with env(COMMITTEE_CONFIG=config_env):
        app = _test_app()
        assert user in app.get('/').get_data(as_text=True)
Beispiel #15
0
def test_app_imports():
    with env(COMMITTEE_CONFIG=config_env):
        app = _import_app()
        assert isinstance(app, flask.Flask)