Skip to content

Commit

Permalink
[BIA 455] Adds DistrictId to rls_UserAuthorization view (#15)
Browse files Browse the repository at this point in the history
* Add District Id to UserAuthorization view. Returns the district id, when user has district level access.

* Add specific tests for DistrictId

* Revert leftover configuration code

* revert connection string change

* Adds DistrictId to UserAuthorization view for Postgres.

Co-authored-by: Arturo Hernandez <[email protected]>
  • Loading branch information
DavidJGapCR and arturohernandez10 authored Sep 24, 2020
1 parent dca7841 commit 0b2e505
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ AS
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN staffToScopeMap.EducationOrganizationId
END AS DistrictId
FROM
staffToScopeMap
LEFT OUTER JOIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ SELECT DISTINCT staffToScopeMap.StaffUniqueId AS UserKey
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN staffToScopeMap.EducationOrganizationId
END AS DistrictId
FROM staffToScopeMap
LEFT OUTER JOIN
edfi.StaffSectionAssociation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ SELECT DISTINCT staffToScopeMap.StaffUniqueId AS UserKey
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN staffToScopeMap.EducationOrganizationId
END AS DistrictId
FROM staffToScopeMap
LEFT OUTER JOIN
edfi.StaffSectionAssociation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ AS
WHEN 'AuthorizationScope.District'
THEN 'ALL'
ELSE CAST(staffToScopeMap.EducationOrganizationId AS VARCHAR)
END AS SchoolPermission
END AS SchoolPermission,
CASE staffToScopeMap.UserScope
WHEN 'AuthorizationScope.District'
THEN staffToScopeMap.EducationOrganizationId
END AS DistrictId
FROM
staffToScopeMap
LEFT OUTER JOIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public class UserAuthorization
public string StudentPermission { get; set; } //(varchar(3), not null)
public string SectionPermission { get; set; } //(varchar(50), null)
public string SchoolPermission { get; set; } //(varchar(30), null)
public int? DistrictId { get; set; } //(int, null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public class Given_an_StaffEducationOrganizationAssignmentAssociation_with_Autho
{
public Given_an_StaffEducationOrganizationAssignmentAssociation_with_AuthorizationScope_equal_to_District(TestHarness dataStandard) => SetDataStandard(dataStandard);

[Test]
public void Then_DistrictId_with_UserScope_equal_to_District_is_returned_properly()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<UserAuthorization>($"{TestCasesFolder}.querying_DistrictId_with_UserScope_equal_to_District.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}
[Test]
public void Then_SchoolPermission_with_UserScope_equal_to_District_is_returned_properly()
{
Expand All @@ -97,6 +103,13 @@ public class Given_an_StaffEducationOrganizationAssignmentAssociation_with_Autho
{
public Given_an_StaffEducationOrganizationAssignmentAssociation_with_AuthorizationScope_equal_to_School(TestHarness dataStandard) => SetDataStandard(dataStandard);

[Test]
public void Then_DistrictId_with_UserScope_equal_to_School_is_returned_properly()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<UserAuthorization>($"{TestCasesFolder}.querying_DistrictId_with_UserScope_equal_to_School.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_SchoolPermission_with_UserScope_equal_to_School_is_returned_properly()
{
Expand All @@ -118,6 +131,13 @@ public class Given_an_StaffEducationOrganizationAssignmentAssociation_with_Autho
{
public Given_an_StaffEducationOrganizationAssignmentAssociation_with_AuthorizationScope_equal_to_Section(TestHarness dataStandard) => SetDataStandard(dataStandard);

[Test]
public void Then_DistrictId_with_UserScope_equal_to_Section_is_returned_properly()
{
(bool success, string errorMessage) testResult = DataStandard.RunTestCase<UserAuthorization>($"{TestCasesFolder}.querying_DistrictId_with_UserScope_equal_to_Section.json");
testResult.success.ShouldBe(true, testResult.errorMessage);
}

[Test]
public void Then_SchoolPermission_with_UserScope_equal_to_Section_is_returned_properly()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
{
"ColumnName": "SchoolPermission",
"DataType": "varchar"
},
{
"ColumnName": "DistrictId",
"DataType": "int"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"DBMS": "Any",
"ControlDataInsertion": "",
"DropControlData": "",
"Query": "select UserScope, DistrictId from analytics.rls_UserAuthorization where UserKey = 13449",
"Result": [
{
"UserScope": "AuthorizationScope.District",
"DistrictId": 867530
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"DBMS": "Any",
"ControlDataInsertion": "",
"DropControlData": "",
"Query": "select UserScope, DistrictId from analytics.rls_UserAuthorization where UserKey = 13630",
"Result": [
{
"UserScope": "AuthorizationScope.School",
"DistrictId": null
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"DBMS": "Any",
"ControlDataInsertion": "",
"DropControlData": "",
"Query": "select UserScope, DistrictId from analytics.rls_UserAuthorization where UserKey = 11331",
"Result": [
{
"UserScope": "AuthorizationScope.Section",
"DistrictId": null
}
]
}

0 comments on commit 0b2e505

Please sign in to comment.