Exemplo n.º 1
0
def verify_pw(username, password):
    is_aaf_enabled = osdf_config.deployment.get('is_aaf_enabled', False)
    if is_aaf_enabled:
        return aaf_auth.authenticate(username, password)
    else:
        pw = get_pw(username)
        return pw == password
Exemplo n.º 2
0
    def test_authenticate_except(self):
        app = Flask(__name__)
        auth.clear_cache()

        def mock_aaf_response2(*args, **kwargs):
            raise Exception('This is the exception you expect to handle')

        with app.test_request_context(path='/api/oof/v1/placement'):
            with mock.patch.object(RestClient,
                                   'request',
                                   side_effect=mock_aaf_response2):
                assert not auth.authenticate('user3', 'password3')
Exemplo n.º 3
0
    def test_authenticate_fail3(self):
        app = Flask(__name__)
        auth.clear_cache()

        def mock_aaf_response2(*args, **kwargs):
            return {}

        with app.test_request_context(path='/api/oof/v1/placement'):
            with mock.patch.object(RestClient,
                                   'request',
                                   side_effect=mock_aaf_response2):
                assert not auth.authenticate('user3', 'password3')
Exemplo n.º 4
0
    def test_auth_cache(self):
        app = Flask(__name__)
        auth.clear_cache()

        def mock_aaf_response(*args, **kwargs):
            return {
                "perm": [{
                    "instance": "menu_ecd",
                    "action": "*",
                    "type": "org.onap.osdf.controller.dev.menu"
                }, {
                    "instance": "*",
                    "action": "read",
                    "type": "org.onap.oof.access"
                }, {
                    "instance": "aaf",
                    "action": "request",
                    "type": "org.onap.osdf.certman"
                }, {
                    "instance": "*",
                    "action": "*",
                    "type": "org.onap.osdf.dev.access"
                }, {
                    "instance": ":*:*",
                    "action": "*",
                    "type": "org.onap.osdf.dev.k8"
                }, {
                    "instance": ":*:*",
                    "action": "*",
                    "type": "org.onap.osdf.ist.k8"
                }]
            }

        with app.test_request_context(path='/api/oof/v1/placement'):
            with mock.patch.object(RestClient,
                                   'request',
                                   side_effect=mock_aaf_response):
                assert auth.authenticate('user', 'password')
                assert auth.authenticate('user', 'password')
Exemplo n.º 5
0
    def test_authenticate_fail(self):
        app = Flask(__name__)
        auth.clear_cache()

        def mock_aaf_response(*args, **kwargs):
            return {
                "perm": [{
                    "instance": "menu_ecd",
                    "action": "*",
                    "type": "org.onap.oof.controller.dev.menu"
                }]
            }

        with app.test_request_context(path='/api/oof/v1/placement'):
            with mock.patch.object(RestClient,
                                   'request',
                                   side_effect=mock_aaf_response):
                assert not auth.authenticate('user1', 'password1')