Esempio n. 1
0
    def test_return_false_for_unauthorised_user(self):
        permissions = Permissions({
            "userone": ["mybucket"],
            "usertwo": ["mybucket"]
        })

        assert_that(permissions.allowed("userthree", "mybucket"), is_(False))
Esempio n. 2
0
    def test_return_true_for_user_in_list_for_bucket(self):
        permissions = Permissions({
            "userone": ["mybucket"],
            "usertwo": ["mybucket"]
        })

        assert_that(permissions.allowed("userone", "mybucket"), is_(True))
Esempio n. 3
0
    def test_return_true_for_user_in_list_for_bucket(self):
        permissions = Permissions({
            "userone": ["mybucket"],
            "usertwo": ["mybucket"]
        })

        assert_that(permissions.allowed("userone", "mybucket"), is_(True))
Esempio n. 4
0
    def test_return_false_for_unauthorised_user(self):
        permissions = Permissions({
            "userone": ["mybucket"],
            "usertwo": ["mybucket"]
        })

        assert_that(permissions.allowed("userthree", "mybucket"), is_(False))
Esempio n. 5
0
    def test_returns_empty_list_for_unknown_user(self):
        session = {
            "user": {
                "email": "*****@*****.**"
            }
        }
        permissions = Permissions({
            "*****@*****.**": ["foo"]
        })

        assert_that(permissions.buckets_in_session(session), is_([]))
Esempio n. 6
0
    def test_returns_list_of_buckets_for_known_user(self):
        session = {
            "user": {
                "email": "*****@*****.**"
            }
        }
        permissions = Permissions({
            "*****@*****.**": ["moj", "fco"],
            "*****@*****.**": ["dvla", "etc"]
        })

        assert_that(permissions.buckets_in_session(session),
                    is_(["moj", "fco"]))
Esempio n. 7
0
    def test_return_false_for_unknown_bucket(self):
        permissions = Permissions({})

        assert_that(permissions.allowed("anyuser", "anybucket"), is_(False))
Esempio n. 8
0
 def given_bucket_permissions(self, bucket, users):
     self.app.permissions = Permissions({bucket: users})
Esempio n. 9
0
    def test_return_false_for_unknown_bucket(self):
        permissions = Permissions({})

        assert_that(permissions.allowed("anyuser", "anybucket"), is_(False))
Esempio n. 10
0
feature_flags = FeatureFlag(app)

# Configuration
app.config.from_object("backdrop.write.config.%s" % environment())

app.config['USER_SCOPE'] = "/_user"

db = database.Database(app.config['MONGO_HOST'], app.config['MONGO_PORT'],
                       app.config['DATABASE_NAME'])

setup_logging()

app.before_request(create_request_logger(app))
app.after_request(create_response_logger(app))

app.permissions = Permissions(app.config["PERMISSIONS"])

app.url_map.converters["bucket"] = BucketConverter

if use_single_sign_on(app):
    app.secret_key = app.config['SECRET_KEY']
    admin_ui.setup(app, db)


@app.errorhandler(500)
@app.errorhandler(405)
@app.errorhandler(404)
def exception_handler(e):
    app.logger.exception(e)

    bucket_name = getattr(g, 'bucket_name', request.path)