Skip to content

Commit

Permalink
Remove HFI role checks (#3549)
Browse files Browse the repository at this point in the history
Co-authored-by: Conor Brady <con.brad@gmail.com>
  • Loading branch information
dgboss and conbrad authored Apr 19, 2024
1 parent 2657d91 commit 097f009
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 132 deletions.
56 changes: 22 additions & 34 deletions api/app/routers/hfi_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
DateRange,
FuelTypesResponse,
HFIWeatherStationsResponse)
from app.auth import (auth_with_select_station_role_required,
auth_with_set_fire_starts_role_required,
auth_with_station_admin_role_required,
auth_with_set_fuel_type_role_required,
auth_with_set_ready_state_required,
authentication_required,
audit)
from app.auth import (
auth_with_station_admin_role_required,
authentication_required,
audit,
# auth_with_select_station_role_required,
# auth_with_set_fire_starts_role_required,
# auth_with_set_fuel_type_role_required,
# auth_with_set_ready_state_required,
)
from app.schemas.shared import (FuelType)
from app.db.crud.hfi_calc import (get_fuel_type_by_id,
get_most_recent_updated_hfi_request,
Expand Down Expand Up @@ -190,11 +192,7 @@ async def get_fuel_types(response: Response) -> FuelTypesResponse:
@router.post("/fire_centre/{fire_centre_id}/{start_date}/{end_date}/planning_area/{planning_area_id}"
"/station/{station_code}/selected/{enable}")
async def set_planning_area_station(
fire_centre_id: int, start_date: date, end_date: date,
planning_area_id: int, station_code: int,
enable: bool,
response: Response,
token=Depends(auth_with_select_station_role_required)
fire_centre_id: int, start_date: date, end_date: date, planning_area_id: int, station_code: int, enable: bool, response: Response, token=Depends(authentication_required)
):
""" Enable / disable a station withing a planning area """
logger.info('/fire_centre/%s/%s/%s/planning_area/%s/station/%s/selected/%s',
Expand Down Expand Up @@ -228,14 +226,7 @@ async def set_planning_area_station(
@router.post("/fire_centre/{fire_centre_id}/{start_date}/{end_date}/planning_area/{planning_area_id}"
"/station/{station_code}/fuel_type/{fuel_type_id}")
async def set_planning_area_station_fuel_type(
fire_centre_id: int,
start_date: date,
end_date: date,
planning_area_id: int,
station_code: int,
fuel_type_id: int,
response: Response,
token=Depends(auth_with_set_fuel_type_role_required)
fire_centre_id: int, start_date: date, end_date: date, planning_area_id: int, station_code: int, fuel_type_id: int, response: Response, token=Depends(authentication_required)
):
""" Set the fuel type for a station in a planning area. """
logger.info("/fire_centre/%s/%s/%s/planning_area/%s/station/%s/fuel_type/%s",
Expand Down Expand Up @@ -272,14 +263,16 @@ async def set_planning_area_station_fuel_type(
@router.post("/fire_centre/{fire_centre_id}/{start_date}/{end_date}/planning_area/{planning_area_id}"
"/fire_starts/{prep_day_date}/fire_start_range/{fire_start_range_id}",
response_model=HFIResultResponse)
async def set_fire_start_range(fire_centre_id: int,
start_date: date,
end_date: date,
planning_area_id: int,
prep_day_date: date,
fire_start_range_id: int,
response: Response,
token=Depends(auth_with_set_fire_starts_role_required)):
async def set_fire_start_range(
fire_centre_id: int,
start_date: date,
end_date: date,
planning_area_id: int,
prep_day_date: date,
fire_start_range_id: int,
response: Response,
token=Depends(authentication_required),
):
""" Set the fire start range, by id."""
logger.info("/fire_centre/%s/%s/%s/planning_area/%s"
"/fire_starts/%s/fire_start_range/%s",
Expand Down Expand Up @@ -412,12 +405,7 @@ async def get_all_ready_records(

@router.post("/fire_centre/{fire_centre_id}/planning_area/{planning_area_id}/{start_date}/{end_date}/ready",
response_model=HFIReadyState)
async def toggle_planning_area_ready(
fire_centre_id: int,
planning_area_id: int,
start_date: date,
end_date: date, response: Response,
token=Depends(auth_with_set_ready_state_required)):
async def toggle_planning_area_ready(fire_centre_id: int, planning_area_id: int, start_date: date, end_date: date, response: Response, token=Depends(authentication_required)):
""" Set the fire start range, by id."""
logger.info("/fire_centre/%s/planning_area/%s/start_date/%s/end_date/%s/ready",
fire_centre_id, planning_area_id, start_date, end_date)
Expand Down
28 changes: 14 additions & 14 deletions api/app/tests/hfi/test_hfi_endpoint_request.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ Feature: /hfi/
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | hfi_set_fire_starts | 200 | hfi/test_hfi_endpoint_response_set_fire_start_range.json | True | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | hfi_set_fire_starts | 200 | hfi/test_hfi_endpoint_response_set_fire_start_range.json | True | test_hfi_endpoint_stored_request.json |
# Test set fire start range without roles
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | None | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | None | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# Test set fire start range without correct role
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | hfi_select_station | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | hfi_select_station | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | hfi_select_station | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/fire_starts/2020-05-21/fire_start_range/2 | hfi_select_station | 401 | None | False | test_hfi_endpoint_stored_request.json |
# Test the station selection with correct role
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | hfi_select_station | 200 | hfi/test_hfi_endpoint_response_deselect_station.json | True | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | hfi_select_station | 200 | hfi/test_hfi_endpoint_response_deselect_station.json | True | test_hfi_endpoint_stored_request.json |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | hfi_select_station | 200 | hfi/test_hfi_endpoint_response_select_station.json | True | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | hfi_select_station | 200 | hfi/test_hfi_endpoint_response_select_station.json | True | test_hfi_endpoint_stored_request.json |
# Test the station selection without roles
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | None | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | None | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | None | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | None | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# Test the station selection without correct role
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | hfi_set_fire_starts | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | hfi_set_fire_starts | 401 | None | False | test_hfi_endpoint_stored_request.json |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | hfi_set_fire_starts | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | hfi_set_fire_starts | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | hfi_set_fire_starts | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/false | hfi_set_fire_starts | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | hfi_set_fire_starts | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/selected/true | hfi_set_fire_starts | 401 | None | False | test_hfi_endpoint_stored_request.json |
# Test set the station fuel type with correct role
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/2 | hfi_set_fuel_type | 200 | hfi/test_hfi_endpoint_response_set_fuel_type.json | True | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/2 | hfi_set_fuel_type | 200 | hfi/test_hfi_endpoint_response_set_fuel_type.json | True | test_hfi_endpoint_stored_request.json |
# Test set the station fuel type without correct role
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/2 | None | 401 | None | False | None |
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/2 | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/2 | None | 401 | None | False | None |
# | /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/2 | None | 401 | None | False | test_hfi_endpoint_stored_request.json |
# Invalid fuel type should return 500 error, and not be saved.
| /api/hfi-calc/fire_centre/1/2020-05-21/2020-05-25/planning_area/1/station/230/fuel_type/-1 | hfi_set_fuel_type | 500 | None | False | None |

49 changes: 0 additions & 49 deletions web/src/features/auth/components/SignoutButton.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions web/src/features/hfiCalculator/components/DailyViewTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { RequiredDataCell } from 'features/hfiCalculator/components/RequiredData
import EmptyFireCentreRow from 'features/hfiCalculator/components/EmptyFireCentre'
import { DailyHFICell } from 'features/hfiCalculator/components/DailyHFICell'
import { StationDataHeaderCells } from 'features/hfiCalculator/components/StationDataHeaderCells'
import { ROLES } from 'features/auth/roles'
/* import { ROLES } from 'features/auth / roles' */
import {
NoBottomBorderCell,
PlanningAreaBorderTableCell,
Expand Down Expand Up @@ -78,7 +78,7 @@ export const dailyTableColumnLabels = [

export const DailyViewTable = (props: Props): JSX.Element => {
const { selectedPrepDate, result } = useSelector(selectHFICalculatorState)
const { roles, isAuthenticated } = useSelector(selectAuthentication)
const { /* roles, */ isAuthenticated } = useSelector(selectAuthentication)

const getDailyForDay = (stationCode: number): StationDaily | undefined => {
const dailiesForStation = getDailiesByStationCode(result, stationCode)
Expand Down Expand Up @@ -299,8 +299,8 @@ export const DailyViewTable = (props: Props): JSX.Element => {
<BaseStationAttributeCells
station={station}
planningAreaId={area.id}
selectStationEnabled={roles.includes(ROLES.HFI.SELECT_STATION) && isAuthenticated}
isSetFuelTypeEnabled={roles.includes(ROLES.HFI.SET_FUEL_TYPE) && isAuthenticated}
selectStationEnabled={/* roles.includes(ROLES.HFI.SELECT_STATION) && */ isAuthenticated}
isSetFuelTypeEnabled={/* roles.includes(ROLES.HFI.SET_FUEL_TYPE) && */ isAuthenticated}
stationCodeInSelected={stationCodeInSelected}
toggleSelectedStation={toggleSelectedStation}
isDailyTable={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import PrepDateRangeSelector from 'features/hfiCalculator/components/PrepDateRan
import LoggedInStatus from 'features/hfiCalculator/components/stationAdmin/LoggedInStatus'
import { selectAuthentication } from 'app/rootReducer'
import { useSelector } from 'react-redux'
import SignoutButton from 'features/auth/components/SignoutButton'

const PREFIX = 'HFIPageSubHeader'

Expand Down Expand Up @@ -69,7 +68,7 @@ interface Props {
}

export const HFIPageSubHeader: React.FunctionComponent<Props> = (props: Props) => {
const { isAuthenticated, roles, idir } = useSelector(selectAuthentication)
const { isAuthenticated, /* roles, */ idir } = useSelector(selectAuthentication)
const [modalOpen, setModalOpen] = useState<boolean>(false)

const openAboutModal = () => {
Expand All @@ -87,8 +86,7 @@ export const HFIPageSubHeader: React.FunctionComponent<Props> = (props: Props) =
dateRange={props.result ? props.result.date_range : undefined}
setDateRange={props.setDateRange}
/>
<LoggedInStatus isAuthenticated={isAuthenticated} roles={roles} idir={idir} />
<SignoutButton />
<LoggedInStatus isAuthenticated={isAuthenticated} /* roles={roles} */ idir={idir} />
<AboutButtonGridItem>
<MinWidthFormControl>
<Button onClick={openAboutModal} size="small">
Expand Down
Loading

0 comments on commit 097f009

Please sign in to comment.