@@ -63,7 +63,7 @@ def setUpTestData(cls):
63
63
cls .superuser = UserFactory (is_superuser = True )
64
64
cls .unicef_organization = Organization .objects .get (name = 'UNICEF' , vendor_number = '000' )
65
65
cls .partnership_manager = UserFactory (
66
- realms__data = ["Partnership Manager" ], email = 'test@unicef.org' ,
66
+ realms__data = ["UNICEF User" , " Partnership Manager" ], email = 'test@unicef.org' ,
67
67
profile__organization = cls .unicef_organization
68
68
)
69
69
@@ -86,7 +86,7 @@ def test_post_revoke_200(self):
86
86
self .assertEqual (response .status_code , status .HTTP_200_OK )
87
87
response = json .loads (response .content )
88
88
self .assertEqual (response ['status' ], 'success' )
89
- self .assertEqual (response ['details' ]['previous_roles' ], ["Partnership Manager" ])
89
+ self .assertEqual (response ['details' ]['previous_roles' ], ["Partnership Manager" , "UNICEF User" ])
90
90
self .assertEqual (response ['details' ]['current_roles' ], [])
91
91
92
92
def test_post_grant_200 (self ):
@@ -105,12 +105,36 @@ def test_post_grant_200(self):
105
105
106
106
response = json .loads (response .content )
107
107
self .assertEqual (response ['status' ], 'success' )
108
- self .assertEqual (response ['details' ]['previous_roles' ], ["Partnership Manager" ])
108
+ self .assertEqual (response ['details' ]['previous_roles' ], ["Partnership Manager" , "UNICEF User" ])
109
109
self .assertEqual (
110
110
response ['details' ]['current_roles' ],
111
111
['Partnership Manager' , 'UNICEF Audit Focal Point' , 'UNICEF User' ]
112
112
)
113
113
114
+ def test_post_grant_reactivate_200 (self ):
115
+ self .partnership_manager .realms .update (is_active = False )
116
+ for realm in self .partnership_manager .realms .all ():
117
+ self .assertFalse (realm .is_active )
118
+ response = self .forced_auth_req (
119
+ "post" ,
120
+ self .url ,
121
+ user = self .superuser ,
122
+ data = {
123
+ "user_email" : self .partnership_manager .email ,
124
+ "roles" : ["UNICEF Audit Focal Point" ],
125
+ "workspace" : f"{ self .tenant .business_area_code } " ,
126
+ "access_type" : "grant"
127
+ }
128
+ )
129
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
130
+
131
+ response = json .loads (response .content )
132
+ self .assertEqual (response ['status' ], 'success' )
133
+ self .assertEqual (response ['details' ]['previous_roles' ], [])
134
+ self .assertEqual (
135
+ response ['details' ]['current_roles' ], ['UNICEF Audit Focal Point' , 'UNICEF User' ]
136
+ )
137
+
114
138
def test_post_set_200 (self ):
115
139
response = self .forced_auth_req (
116
140
"post" ,
@@ -127,7 +151,7 @@ def test_post_set_200(self):
127
151
128
152
response = json .loads (response .content )
129
153
self .assertEqual (response ['status' ], 'success' )
130
- self .assertEqual (response ['details' ]['previous_roles' ], ["Partnership Manager" ])
154
+ self .assertEqual (response ['details' ]['previous_roles' ], ["Partnership Manager" , "UNICEF User" ])
131
155
self .assertEqual (response ['details' ]['current_roles' ], ["UNICEF Audit Focal Point" , "UNICEF User" ])
132
156
133
157
def test_invalid_uppercase_email (self ):
0 commit comments