@pytest.mark.parametrize('test_name,state,filing_type,sub_filing_type,legal_types,username,roles,expected', [('staff_active_allowed', Business.State.ACTIVE, 'alteration', None, ['BC', 'BEN', 'ULC'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'alteration', None, ['CP', 'CC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'annualReport', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'annualReport', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'changeOfAddress', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'changeOfAddress', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'changeOfDirectors', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'changeOfDirectors', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'correction', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'correction', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'incorporationApplication', None, ['CP', 'BC', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active', Business.State.ACTIVE, 'restoration', 'limitedRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'specialResolution', None, ['CP'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'specialResolution', None, ['BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'transition', None, ['BC', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'transition', None, ['CP', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'registration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'changeOfRegistration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], True), ('user_active_allowed', Business.State.ACTIVE, 'alteration', None, ['BC', 'BEN', 'ULC'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'alteration', None, ['CP', 'CC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'annualReport', None, ['CP', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'annualReport', None, ['BC', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'changeOfAddress', None, ['CP', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'changeOfAddress', None, ['BC', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'changeOfDirectors', None, ['CP', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'changeOfDirectors', None, ['BC', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'correction', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP'], 'user', [BASIC_USER], True), ('user_active_allowed', Business.State.ACTIVE, 'incorporationApplication', None, ['CP', 'BC', 'BEN'], 'user', [BASIC_USER], True), ('user_active_allowed', Business.State.ACTIVE, 'registration', None, ['SP', 'GP'], 'user', [BASIC_USER], True), ('user_active_allowed', Business.State.ACTIVE, 'changeOfRegistration', None, ['SP', 'GP'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'restoration', 'limitedRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'specialResolution', None, ['CP'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'specialResolution', None, ['BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'transition', None, ['BC', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'transition', None, ['CP', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('staff_historical', Business.State.HISTORICAL, 'alteration', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'annualReport', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'changeOfAddress', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'changeOfDirectors', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'correction', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical_allowed', Business.State.HISTORICAL, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical', Business.State.HISTORICAL, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'incorporationApplication', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical_allowed', Business.State.HISTORICAL, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical_allowed', Business.State.HISTORICAL, 'restoration', 'limitedRestoration', ['BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical', Business.State.HISTORICAL, 'restoration', 'limitedRestoration', ['CP'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'specialResolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'transition', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical_allowed', Business.State.HISTORICAL, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical_allowed', Business.State.HISTORICAL, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical', Business.State.HISTORICAL, 'registration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'changeOfRegistration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], False), ('user_historical', Business.State.HISTORICAL, 'alteration', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'annualReport', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'changeOfAddress', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'changeOfDirectors', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'correction', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP', 'SP', 'GP'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'incorporationApplication', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'restoration', 'limitedRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'specialResolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'transition', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'registration', None, ['SP', 'GP'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'changeOfRegistration', None, ['SP', 'GP'], 'user', [BASIC_USER], False)])
def test_is_allowed(monkeypatch, app, jwt, test_name, state, filing_type, sub_filing_type, legal_types, username, roles, expected):
    'Assert that get allowed returns valid filings.'
    token = helper_create_jwt(jwt, roles=roles, username=username)
    headers = {'Authorization': ('Bearer ' + token)}

    def mock_auth(one, two):
        return headers[one]
    with app.test_request_context():
        monkeypatch.setattr('flask.request.headers.get', mock_auth)
        for legal_type in legal_types:
            filing_types = is_allowed(state, filing_type, legal_type, jwt, sub_filing_type)
            assert (filing_types == expected)
Assert that get allowed returns valid filings.
@pytest.mark.parametrize('test_name,state,filing_type,sub_filing_type,legal_types,username,roles,expected', [('staff_active_allowed', Business.State.ACTIVE, 'alteration', None, ['BC', 'BEN', 'ULC'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'alteration', None, ['CP', 'CC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'annualReport', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'annualReport', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'changeOfAddress', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'changeOfAddress', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'changeOfDirectors', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'changeOfDirectors', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'correction', None, ['CP', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'correction', None, ['BC', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'incorporationApplication', None, ['CP', 'BC', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active', Business.State.ACTIVE, 'restoration', 'limitedRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'specialResolution', None, ['CP'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'specialResolution', None, ['BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'transition', None, ['BC', 'BEN'], 'staff', [STAFF_ROLE], True), ('staff_active', Business.State.ACTIVE, 'transition', None, ['CP', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_active_allowed', Business.State.ACTIVE, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'registration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], True), ('staff_active_allowed', Business.State.ACTIVE, 'changeOfRegistration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], True), ('user_active_allowed', Business.State.ACTIVE, 'alteration', None, ['BC', 'BEN', 'ULC'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'alteration', None, ['CP', 'CC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'annualReport', None, ['CP', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'annualReport', None, ['BC', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'changeOfAddress', None, ['CP', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'changeOfAddress', None, ['BC', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'changeOfDirectors', None, ['CP', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'changeOfDirectors', None, ['BC', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'correction', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP'], 'user', [BASIC_USER], True), ('user_active_allowed', Business.State.ACTIVE, 'incorporationApplication', None, ['CP', 'BC', 'BEN'], 'user', [BASIC_USER], True), ('user_active_allowed', Business.State.ACTIVE, 'registration', None, ['SP', 'GP'], 'user', [BASIC_USER], True), ('user_active_allowed', Business.State.ACTIVE, 'changeOfRegistration', None, ['SP', 'GP'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'restoration', 'limitedRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'specialResolution', None, ['CP'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'specialResolution', None, ['BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active_allowed', Business.State.ACTIVE, 'transition', None, ['BC', 'BEN'], 'user', [BASIC_USER], True), ('user_active', Business.State.ACTIVE, 'transition', None, ['CP', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_active', Business.State.ACTIVE, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('staff_historical', Business.State.HISTORICAL, 'alteration', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'annualReport', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'changeOfAddress', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'changeOfDirectors', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'correction', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical_allowed', Business.State.HISTORICAL, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical', Business.State.HISTORICAL, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'incorporationApplication', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical_allowed', Business.State.HISTORICAL, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical_allowed', Business.State.HISTORICAL, 'restoration', 'limitedRestoration', ['BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical', Business.State.HISTORICAL, 'restoration', 'limitedRestoration', ['CP'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'specialResolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'transition', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], False), ('staff_historical_allowed', Business.State.HISTORICAL, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical_allowed', Business.State.HISTORICAL, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'staff', [STAFF_ROLE], True), ('staff_historical', Business.State.HISTORICAL, 'registration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], False), ('staff_historical', Business.State.HISTORICAL, 'changeOfRegistration', None, ['SP', 'GP'], 'staff', [STAFF_ROLE], False), ('user_historical', Business.State.HISTORICAL, 'alteration', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'annualReport', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'changeOfAddress', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'changeOfDirectors', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'correction', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'courtOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'dissolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC', 'SP', 'GP', 'SP', 'GP'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'incorporationApplication', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'restoration', 'fullRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'restoration', 'limitedRestoration', ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'specialResolution', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'transition', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'registrarsNotation', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'registrarsOrder', None, ['CP', 'BC', 'BEN', 'CC', 'ULC', 'LLC'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'registration', None, ['SP', 'GP'], 'user', [BASIC_USER], False), ('user_historical', Business.State.HISTORICAL, 'changeOfRegistration', None, ['SP', 'GP'], 'user', [BASIC_USER], False)])
def test_is_allowed(monkeypatch, app, jwt, test_name, state, filing_type, sub_filing_type, legal_types, username, roles, expected):
    
    token = helper_create_jwt(jwt, roles=roles, username=username)
    headers = {'Authorization': ('Bearer ' + token)}

    def mock_auth(one, two):
        return headers[one]
    with app.test_request_context():
        monkeypatch.setattr('flask.request.headers.get', mock_auth)
        for legal_type in legal_types:
            filing_types = is_allowed(state, filing_type, legal_type, jwt, sub_filing_type)
            assert (filing_types == expected)