-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from NDLANO/use-primary-affiliation-if-present
Extra check for primary affiliation
- Loading branch information
Showing
7 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ class ArenaTest | |
when(feideApiClient.getFeideAccessTokenOrFail(any)).thenReturn(Success("notimportante")) | ||
when(feideApiClient.getFeideGroups(any)).thenReturn(Success(Seq.empty)) | ||
when(feideApiClient.getFeideExtendedUser(any)) | ||
.thenReturn(Success(FeideExtendedUserInfo("", Seq("employee"), "[email protected]", Seq("[email protected]")))) | ||
.thenReturn(Success(FeideExtendedUserInfo("", Seq("employee"), None, "[email protected]", Seq("[email protected]")))) | ||
when(feideApiClient.getOrganization(any)).thenReturn(Success("zxc")) | ||
when(configService.getMyNDLAEnabledOrgs).thenReturn(Success(List("zxc"))) | ||
when(clock.now()).thenReturn(someDate) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,9 @@ class CloneFolderTest | |
when(feideApiClient.getFeideAccessTokenOrFail(any)).thenReturn(Success("notimportante")) | ||
when(feideApiClient.getFeideGroups(any)).thenReturn(Success(Seq.empty)) | ||
when(feideApiClient.getFeideExtendedUser(any)) | ||
.thenReturn(Success(FeideExtendedUserInfo("", Seq("employee"), "[email protected]", Seq("[email protected]")))) | ||
.thenReturn( | ||
Success(FeideExtendedUserInfo("", Seq("employee"), Some("employee"), "[email protected]", Seq("[email protected]"))) | ||
) | ||
when(feideApiClient.getOrganization(any)).thenReturn(Success("zxc")) | ||
when(clock.now()).thenReturn(NDLADate.of(2017, 1, 1, 1, 59)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment { | |
val feideUserInfo = FeideExtendedUserInfo( | ||
displayName = "David", | ||
eduPersonAffiliation = Seq("student"), | ||
None, | ||
eduPersonPrincipalName = "[email protected]", | ||
mail = Seq("[email protected]") | ||
) | ||
|
@@ -329,6 +330,7 @@ class UserServiceTest extends UnitTestSuite with TestEnvironment { | |
val updatedFeideUser = FeideExtendedUserInfo( | ||
displayName = "name", | ||
eduPersonAffiliation = Seq.empty, | ||
None, | ||
eduPersonPrincipalName = "[email protected]", | ||
mail = Seq("[email protected]") | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
network/src/test/scala/no/ndla/network/clients/FeideApiClientTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Part of NDLA network | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
* | ||
*/ | ||
|
||
package no.ndla.network.clients | ||
|
||
import no.ndla.network.UnitSuite | ||
|
||
class FeideApiClientTest extends UnitSuite { | ||
|
||
test("testFeideExtendedUserInfo roles") { | ||
val user = FeideExtendedUserInfo("", Seq.empty, None, "", Seq("")) | ||
assert(!user.isTeacher) | ||
|
||
val member = user.copy(eduPersonAffiliation = Seq("member")) | ||
assert(!member.isTeacher) | ||
|
||
val student = user.copy(eduPersonAffiliation = Seq("member", "student")) | ||
assert(!student.isTeacher) | ||
|
||
val studentWithPrimary = | ||
user.copy(eduPersonAffiliation = Seq("member", "student"), eduPersonPrimaryAffiliation = Some("student")) | ||
assert(!studentWithPrimary.isTeacher) | ||
|
||
val staff = user.copy(eduPersonAffiliation = Seq("member", "staff")) | ||
assert(staff.isTeacher) | ||
|
||
val faculty = user.copy(eduPersonAffiliation = Seq("member", "faculty")) | ||
assert(faculty.isTeacher) | ||
|
||
val employee = user.copy(eduPersonAffiliation = Seq("member", "employee")) | ||
assert(employee.isTeacher) | ||
|
||
val employeeWithStudent = user.copy(eduPersonAffiliation = Seq("member", "employee", "student")) | ||
assert(employeeWithStudent.isTeacher) | ||
|
||
val studentWithEmployee = user.copy( | ||
eduPersonAffiliation = Seq("member", "student", "employee"), | ||
eduPersonPrimaryAffiliation = Some("student") | ||
) | ||
assert(!studentWithEmployee.isTeacher) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,7 @@ class SearchControllerTest extends UnitSuite with TestEnvironment with TapirCont | |
val teacheruser = FeideExtendedUserInfo( | ||
displayName = "Johnny Bravo", | ||
eduPersonAffiliation = Seq("employee", "staff"), | ||
eduPersonPrimaryAffiliation = None, | ||
eduPersonPrincipalName = "[email protected]", | ||
mail = Seq("[email protected]") | ||
) | ||
|