@@ -14,11 +14,13 @@ import fi.espoo.evaka.shared.dev.DevDaycare
14
14
import fi.espoo.evaka.shared.dev.DevEmployee
15
15
import fi.espoo.evaka.shared.dev.insert
16
16
import fi.espoo.evaka.shared.domain.FiniteDateRange
17
+ import fi.espoo.evaka.shared.domain.Forbidden
17
18
import fi.espoo.evaka.shared.domain.RealEvakaClock
18
19
import java.util.*
19
20
import kotlin.test.Test
20
21
import kotlin.test.assertEquals
21
22
import org.junit.jupiter.api.BeforeEach
23
+ import org.junit.jupiter.api.assertThrows
22
24
import org.springframework.beans.factory.annotation.Autowired
23
25
24
26
class OutOfOfficeIntegrationTest : FullApplicationTest (resetDbBeforeEach = true ) {
@@ -91,4 +93,45 @@ class OutOfOfficeIntegrationTest : FullApplicationTest(resetDbBeforeEach = true)
91
93
outOfOfficeController.getOutOfOfficePeriods(dbInstance(), employee, clock)
92
94
assertEquals(0 , deletedPeriods.size)
93
95
}
96
+
97
+ @Test
98
+ fun `ordinary employees cannot see or create out of office periods` () {
99
+ val ordinaryEmployee =
100
+ AuthenticatedUser .Employee (
101
+ id = EmployeeId (UUID .randomUUID()),
102
+ roles = setOf (UserRole .STAFF ),
103
+ )
104
+
105
+ db.transaction { tx ->
106
+ tx.insert(DevEmployee (id = ordinaryEmployee.id))
107
+ tx.insertDaycareAclRow(
108
+ daycareId = daycare.id,
109
+ employeeId = ordinaryEmployee.id,
110
+ UserRole .STAFF ,
111
+ )
112
+ }
113
+
114
+ val period =
115
+ OutOfOfficePeriodUpsert (
116
+ id = null ,
117
+ period =
118
+ FiniteDateRange (
119
+ start = clock.today().plusDays(1 ),
120
+ end = clock.today().plusDays(2 ),
121
+ ),
122
+ )
123
+
124
+ assertThrows<Forbidden > {
125
+ outOfOfficeController.getOutOfOfficePeriods(dbInstance(), ordinaryEmployee, clock)
126
+ }
127
+
128
+ assertThrows<Forbidden > {
129
+ outOfOfficeController.upsertOutOfOfficePeriod(
130
+ dbInstance(),
131
+ ordinaryEmployee,
132
+ clock,
133
+ period,
134
+ )
135
+ }
136
+ }
94
137
}
0 commit comments