Fix Organizations model and persistence format (#512)

This commit is contained in:
Brian Yencho
2024-01-06 16:24:29 -06:00
committed by GitHub
parent b1fda8f81d
commit 45fd9d9f1b
5 changed files with 15 additions and 113 deletions

View File

@@ -257,11 +257,12 @@ class AuthDiskSourceTest {
createMockOrganization(0),
createMockOrganization(1),
)
val mockOrganizationsMap = mockOrganizations.associateBy { it.id }
fakeSharedPreferences
.edit()
.putString(
"${organizationsBaseKey}_$mockUserId",
json.encodeToString(mockOrganizations),
json.encodeToString(mockOrganizationsMap),
)
.apply()
val actual = authDiskSource.getOrganizations(userId = mockUserId)
@@ -300,6 +301,7 @@ class AuthDiskSourceTest {
createMockOrganization(0),
createMockOrganization(1),
)
val mockOrganizationsMap = mockOrganizations.associateBy { it.id }
authDiskSource.storeOrganizations(
userId = mockUserId,
organizations = mockOrganizations,
@@ -309,7 +311,7 @@ class AuthDiskSourceTest {
null,
)
assertEquals(
json.encodeToJsonElement(mockOrganizations),
json.encodeToJsonElement(mockOrganizationsMap),
json.parseToJsonElement(requireNotNull(actual)),
)
}

View File

@@ -38,13 +38,9 @@ fun createMockOrganization(number: Int): SyncResponseJson.Profile.Organization =
seats = 1,
isEnabled = false,
providerType = 1,
isResetPasswordEnrolled = false,
shouldUseSecretsManager = false,
maxCollections = 1,
isSelfHost = false,
shouldUseKeyConnector = false,
permissions = createMockPermissions(),
hasPublicAndPrivateKeys = false,
providerId = "mockProviderId-$number",
id = "mockId-$number",
shouldUseGroups = false,
@@ -54,25 +50,15 @@ fun createMockOrganization(number: Int): SyncResponseJson.Profile.Organization =
shouldUsersGetPremium = false,
maxStorageGb = 1,
identifier = "mockIdentifier-$number",
shouldUseSso = false,
shouldUseCustomPermissions = false,
isFamilySponsorshipAvailable = false,
shouldUseResetPassword = false,
planProductType = 1,
accessSecretsManager = false,
use2fa = false,
familySponsorshipToDelete = false,
userId = "mockUserId-$number",
shouldUseActivateAutofillPolicy = false,
shouldUseEvents = false,
familySponsorshipFriendlyName = "mockFamilySponsorshipFriendlyName-$number",
isKeyConnectorEnabled = false,
shouldUseTotp = false,
familySponsorshipLastSyncDate = ZonedDateTime.parse("2023-10-27T12:00:00Z"),
shouldUseScim = false,
name = "mockName-$number",
shouldUseApi = false,
isSsoBound = false,
familySponsorshipValidUntil = ZonedDateTime.parse("2023-10-27T12:00:00Z"),
status = 1,
)
@@ -97,7 +83,6 @@ fun createMockPermissions(): SyncResponseJson.Profile.Permissions =
shouldManageSso = false,
shouldDeleteAssignedCollections = false,
shouldManageUsers = false,
shouldManageScim = false,
shouldAccessImportExport = false,
shouldEditAnyCollection = false,
shouldAccessEventLogs = false,

View File

@@ -50,11 +50,8 @@ private const val SYNC_SUCCESS_JSON = """
"seats": 1,
"enabled": false,
"providerType": 1,
"resetPasswordEnrolled": false,
"useSecretsManager": false,
"maxCollections": 1,
"selfHost": false,
"useKeyConnector": false,
"permissions": {
"manageGroups": false,
"manageResetPassword": false,
@@ -64,14 +61,12 @@ private const val SYNC_SUCCESS_JSON = """
"manageSso": false,
"deleteAssignedCollections": false,
"manageUsers": false,
"manageScim": false,
"accessImportExport": false,
"editAnyCollection": false,
"accessEventLogs": false,
"createNewCollections": false,
"editAssignedCollections": false
},
"hasPublicAndPrivateKeys": false,
"providerId": "mockProviderId-1",
"id": "mockId-1",
"useGroups": false,
@@ -81,25 +76,15 @@ private const val SYNC_SUCCESS_JSON = """
"usersGetPremium": false,
"maxStorageGb": 1,
"identifier": "mockIdentifier-1",
"useSso": false,
"useCustomPermissions": false,
"familySponsorshipAvailable": false,
"useResetPassword": false,
"planProductType": 1,
"accessSecretsManager": false,
"use2fa": false,
"familySponsorshipToDelete": false,
"userId": "mockUserId-1",
"useActivateAutofillPolicy": false,
"useEvents": false,
"familySponsorshipFriendlyName": "mockFamilySponsorshipFriendlyName-1",
"keyConnectorEnabled": false,
"useTotp": false,
"familySponsorshipLastSyncDate": "2023-10-27T12:00:00.00Z",
"useScim": false,
"name": "mockName-1",
"useApi": false,
"ssoBound": false,
"familySponsorshipValidUntil": "2023-10-27T12:00:00.00Z",
"status": 1
}
@@ -116,7 +101,6 @@ private const val SYNC_SUCCESS_JSON = """
"manageSso": false,
"deleteAssignedCollections": false,
"manageUsers": false,
"manageScim": false,
"accessImportExport": false,
"editAnyCollection": false,
"accessEventLogs": false,
@@ -140,11 +124,8 @@ private const val SYNC_SUCCESS_JSON = """
"seats": 1,
"enabled": false,
"providerType": 1,
"resetPasswordEnrolled": false,
"useSecretsManager": false,
"maxCollections": 1,
"selfHost": false,
"useKeyConnector": false,
"permissions": {
"manageGroups": false,
"manageResetPassword": false,
@@ -154,14 +135,12 @@ private const val SYNC_SUCCESS_JSON = """
"manageSso": false,
"deleteAssignedCollections": false,
"manageUsers": false,
"manageScim": false,
"accessImportExport": false,
"editAnyCollection": false,
"accessEventLogs": false,
"createNewCollections": false,
"editAssignedCollections": false
},
"hasPublicAndPrivateKeys": false,
"providerId": "mockProviderId-1",
"id": "mockId-1",
"useGroups": false,
@@ -171,25 +150,15 @@ private const val SYNC_SUCCESS_JSON = """
"usersGetPremium": false,
"maxStorageGb": 1,
"identifier": "mockIdentifier-1",
"useSso": false,
"useCustomPermissions": false,
"familySponsorshipAvailable": false,
"useResetPassword": false,
"planProductType": 1,
"accessSecretsManager": false,
"use2fa": false,
"familySponsorshipToDelete": false,
"userId": "mockUserId-1",
"useActivateAutofillPolicy": false,
"useEvents": false,
"familySponsorshipFriendlyName": "mockFamilySponsorshipFriendlyName-1",
"keyConnectorEnabled": false,
"useTotp": false,
"familySponsorshipLastSyncDate": "2023-10-27T12:00:00.00Z",
"useScim": false,
"name": "mockName-1",
"useApi": false,
"ssoBound": false,
"familySponsorshipValidUntil": "2023-10-27T12:00:00.00Z",
"status": 1
}