Example #1
0
 def setUp(self):
     self.databaseFd, APP.config['DATABASE'] = mkstemp(suffix='test.db')
     APP.config['TESTING'] = True
     self.app = APP.test_client()
     with APP.app_context():
         ayeaye.initializeDatabase(APP.config['DATABASE'])
     self.database = sqlite3.connect(APP.config['DATABASE'])
Example #2
0
from api import APP


if __name__ == "__main__":
    APP.run(host="0.0.0.0", port=8000)
Example #3
0
"""
	Main file to run the app
"""
from api import APP
if __name__ == '__main__':
    # Run the application
    APP.run()
Example #4
0
    def setUp(self):
        """
            Set up test data
        """
        self.app = APP.test_client()
        self.app.testing = True

        self.sample_user = {
            'id': uuid.uuid4().hex,
            'username': '******',
            'email': '*****@*****.**',
            'password': '******',
            'confirm_password': '******'
        }
        self.exist_user = {
            'id': uuid.uuid4().hex,
            'username': '******',
            'email': '*****@*****.**',
            'password': '******',
            'confirm_password': '******'
        }
        self.business_data = {
            'id': uuid.uuid4().hex,
            'name': 'Inzora rooftop coffee',
            'description': 'We have best coffee for you,',
            'country': 'Kenya',
            'city': 'Nairobi'
        }
        save_user = User()
        save_user.save({
            'id': self.sample_user['id'],
            'username': self.sample_user['username'],
            'email': self.sample_user['email'],
            'password': self.sample_user['password'],
            'confirm_password': self.sample_user['confirm_password']
        })
        # Save business for reviews testing
        self.rev_business_data = {
            'id': uuid.uuid4().hex,
            'name': 'KFC',
            'description': 'Finger lickin\' good',
            'country': 'Kenya',
            'city': 'Nairobi'
        }
        # Add user(owner) to the business data dict
        self.rev_business_data['user_id'] = self.sample_user['id']
        # Save business in the storage list for testing
        Business.save(self.rev_business_data)
        with APP.test_request_context():
            # Orphan id: User id that will be used to create an orphan token
            orphan_id = uuid.uuid4().hex
            save_user.save({
                'id':
                orphan_id,
                'username':
                "******",
                'email':
                "*****@*****.**",
                'password':
                self.exist_user['password'],
                'confirm_password':
                self.exist_user['confirm_password']
            })
            # Issue a token the the test user (sample_user)
            # Store test token in auth storage auth_token list
            token = get_token(self.sample_user['id'])
            # Orphan token: User token that do not have any registered business
            orphan_token = get_token(orphan_id)
            expired_token = get_token(self.sample_user['id'], -3600)
            # Create bad signature token
            # Bad signature: #nt secret key from the one used in our API used
            # to hash tokens
            other_signature_token = get_token(self.sample_user['id'], 3600,
                                              'other_signature')
            User().add_token(token)
            User().add_token(expired_token)
            User().add_token(orphan_token)
            User().add_token(other_signature_token)
            self.test_token = token
            self.expired_test_token = expired_token
            self.other_signature_token = other_signature_token
            self.orphan_test_token = orphan_token
Example #5
0
#!/usr/bin/env python
"""wsgi.py -- Part of ddns-server
Copyright (C) 2021 foorensic

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

https://github.com/foorensic/ddns-server

"""
from api import APP

if __name__ == "__main__":
    APP.run(host='0.0.0.0')
Example #6
0
 def setUp(self):
     disable_custom_logging()
     APP.testing = True
     self.client = APP.test_client()
Example #7
0
from api import APP

if __name__ == "__main__":
    APP.run(host='0.0.0.0', port=8080, debug=True)
Example #8
0
    # Set logger on Flask App
    APP.logger.setLevel(level)
    APP.logger.addHandler(handler)


def get_port():
    """
    get listening port
    """

    if 'ELQ_WEBHOOK_SERVICE_PORT' in environ:
        return int(environ['ELQ_WEBHOOK_SERVICE_PORT'])

    return 5000


if __name__ == '__main__':

    DEBUG_MODE = False

    if ENV == '${OPENSHIFT_PROJECT_NAME_DEV}':
        set_log_levels(logging.DEBUG)
    elif ENV == '${OPENSHIFT_PROJECT_NAME_PROD}':
        set_log_levels(logging.INFO)
    else:
        set_log_levels(logging.DEBUG)
        DEBUG_MODE = True

    APP.run(host='0.0.0.0', port=get_port(), debug=DEBUG_MODE)
Example #9
0
from api import APP

if __name__ == '__main__':
    APP.run(host='0.0.0.0', debug=True)