File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -902,15 +902,15 @@ def reconcile_single_keycloak_org(keycloak_org: OrganizationRepresentation):
902902 name = keycloak_org .name ,
903903 sso_organization_id = keycloak_org .id ,
904904 org_key = keycloak_org .alias [:ORG_KEY_MAX_LENGTH ],
905- description = keycloak_org .description ,
905+ description = keycloak_org .description or "" ,
906906 )
907907 log .info ("Created organization %s from Keycloak" , page )
908908 created_flag = True
909909 else :
910910 # Don't update the org_key, because course keys are tied to it.
911911 page .name = keycloak_org .name
912912 page .title = keycloak_org .name
913- page .description = keycloak_org .description
913+ page .description = keycloak_org .description or ""
914914 log .info ("Updated organization %s from Keycloak" , page )
915915
916916 return (page , created_flag )
Original file line number Diff line number Diff line change @@ -747,6 +747,32 @@ def test_reconcile_bad_keycloak_org(mocker):
747747 assert "Organization with this Org key already exists." in str (exc )
748748
749749
750+ def test_reconcile_keycloak_org_without_description ():
751+ """Test that reconciliation works when Keycloak org has no description"""
752+
753+ if not OrganizationIndexPage .objects .exists ():
754+ factories .OrganizationIndexPageFactory .create ()
755+
756+ # Test with None description (new org)
757+ org = factories .OrganizationRepresentationFactory .create (description = None )
758+ page , created = reconcile_single_keycloak_org (org )
759+ assert created is True
760+ assert page .description == ""
761+
762+ parent_org_page = OrganizationIndexPage .objects .first ()
763+ parent_org_page .add_child (instance = page )
764+ page .save () # Should not raise IntegrityError
765+
766+ # Test updating an existing org with None description
767+ org_update = factories .OrganizationRepresentationFactory .create (
768+ id = org .id , name = "Updated Name" , description = None
769+ )
770+ page_updated , created_update = reconcile_single_keycloak_org (org_update )
771+ assert created_update is False
772+ assert page_updated .description == ""
773+ page_updated .save () # Should not raise IntegrityError
774+
775+
750776def test_user_add_b2b_org (mocked_b2b_org_attach ):
751777 """Ensure adding a user to an organization works as expected."""
752778
You can’t perform that action at this time.
0 commit comments