@@ -46,6 +46,7 @@ def test_application_registration_user(self):
4646 "client_secret" : "client_secret" ,
4747 "client_type" : Application .CLIENT_CONFIDENTIAL ,
4848 "redirect_uris" : "http://example.com" ,
49+ "post_logout_redirect_uris" : "http://other_example.com" ,
4950 "authorization_grant_type" : Application .GRANT_AUTHORIZATION_CODE ,
5051 "algorithm" : "" ,
5152 }
@@ -55,13 +56,22 @@ def test_application_registration_user(self):
5556
5657 app = get_application_model ().objects .get (name = "Foo app" )
5758 self .assertEqual (app .user .username , "foo_user" )
59+ app = Application .objects .get ()
60+ self .assertEquals (app .name , form_data ["name" ])
61+ self .assertEquals (app .client_id , form_data ["client_id" ])
62+ self .assertEquals (app .redirect_uris , form_data ["redirect_uris" ])
63+ self .assertEquals (app .post_logout_redirect_uris , form_data ["post_logout_redirect_uris" ])
64+ self .assertEquals (app .client_type , form_data ["client_type" ])
65+ self .assertEquals (app .authorization_grant_type , form_data ["authorization_grant_type" ])
66+ self .assertEquals (app .algorithm , form_data ["algorithm" ])
5867
5968
6069class TestApplicationViews (BaseTest ):
6170 def _create_application (self , name , user ):
6271 app = Application .objects .create (
6372 name = name ,
6473 redirect_uris = "http://example.com" ,
74+ post_logout_redirect_uris = "http://other_example.com" ,
6575 client_type = Application .CLIENT_CONFIDENTIAL ,
6676 authorization_grant_type = Application .GRANT_AUTHORIZATION_CODE ,
6777 user = user ,
@@ -93,9 +103,37 @@ def test_application_detail_owner(self):
93103
94104 response = self .client .get (reverse ("oauth2_provider:detail" , args = (self .app_foo_1 .pk ,)))
95105 self .assertEqual (response .status_code , 200 )
106+ self .assertContains (response , self .app_foo_1 .name )
107+ self .assertContains (response , self .app_foo_1 .redirect_uris )
108+ self .assertContains (response , self .app_foo_1 .post_logout_redirect_uris )
109+ self .assertContains (response , self .app_foo_1 .client_type )
110+ self .assertContains (response , self .app_foo_1 .authorization_grant_type )
96111
97112 def test_application_detail_not_owner (self ):
98113 self .client .login (username = "foo_user" , password = "123456" )
99114
100115 response = self .client .get (reverse ("oauth2_provider:detail" , args = (self .app_bar_1 .pk ,)))
101116 self .assertEqual (response .status_code , 404 )
117+
118+ def test_application_udpate (self ):
119+ self .client .login (username = "foo_user" , password = "123456" )
120+
121+ form_data = {
122+ "client_id" : "new_client_id" ,
123+ "redirect_uris" : "http://new_example.com" ,
124+ "post_logout_redirect_uris" : "http://new_other_example.com" ,
125+ "client_type" : Application .CLIENT_PUBLIC ,
126+ "authorization_grant_type" : Application .GRANT_OPENID_HYBRID ,
127+ }
128+ response = self .client .post (
129+ reverse ("oauth2_provider:update" , args = (self .app_foo_1 .pk ,)),
130+ data = form_data ,
131+ )
132+ self .assertRedirects (response , reverse ("oauth2_provider:detail" , args = (self .app_foo_1 .pk ,)))
133+
134+ self .app_foo_1 .refresh_from_db ()
135+ self .assertEquals (self .app_foo_1 .client_id , form_data ["client_id" ])
136+ self .assertEquals (self .app_foo_1 .redirect_uris , form_data ["redirect_uris" ])
137+ self .assertEquals (self .app_foo_1 .post_logout_redirect_uris , form_data ["post_logout_redirect_uris" ])
138+ self .assertEquals (self .app_foo_1 .client_type , form_data ["client_type" ])
139+ self .assertEquals (self .app_foo_1 .authorization_grant_type , form_data ["authorization_grant_type" ])
0 commit comments