예제 #1
0
def create():
    """Create application."""
    form = ApplicationForm()
    if form.validate_on_submit():
        OAuthClient.create(user=current_user,
                           name=form.name.data,
                           desc=form.desc.data,
                           website=form.website.data,
                           redirect_uri=form.redirect_uri.data)
        flash(gettext('You have created an application!'), 'success')
        return redirect(url_for('.index'))
    return render_template('profile/applications/create.html', form=form)
예제 #2
0
def create():
    """Create application."""
    form = ApplicationForm()
    if form.validate_on_submit():
        OAuthClient.create(
            user=current_user,
            name=form.name.data,
            desc=form.desc.data,
            website=form.website.data,
            redirect_uri=form.redirect_uri.data,
        )
        flash(gettext("You have created an application!"), "success")
        return redirect(url_for(".index"))
    return render_template("profile/applications/create.html", form=form)
예제 #3
0
 def create_dummy_client(self, user):
     client = OAuthClient.create(
         user=user,
         name="Dummy Client",
         desc="Created for testing the webservice",
         website="http://example.com/",
         redirect_uri="http://example.com/redirect/",
     )
     return client
예제 #4
0
 def create_dummy_client(self, user):
     client = OAuthClient.create(
         user=user,
         name="Dummy Client",
         desc="Created for testing the webservice",
         website="http://example.com/",
         redirect_uri="http://example.com/redirect/",
     )
     return client
    def test_delete(self):
        oauth_client = OAuthClient.create(
            user=self.user,
            name=u'Test App',
            desc=u'Application for testing.',
            website=u'https://example.com',
            redirect_uri=u'https://example.com/oauth',
        )
        self.assertEqual(OAuthClient.query.count(), 1)

        oauth_client.delete()
        self.assertEqual(OAuthClient.query.count(), 0)
예제 #6
0
    def test_delete(self):
        oauth_client = OAuthClient.create(
            user=self.user,
            name=u'Test App',
            desc=u'Application for testing.',
            website=u'https://example.com',
            redirect_uri=u'https://example.com/oauth',
        )
        self.assertEqual(OAuthClient.query.count(), 1)

        oauth_client.delete()
        self.assertEqual(OAuthClient.query.count(), 0)
    def test_create(self):
        self.assertEqual(OAuthClient.query.count(), 0)

        new_client = OAuthClient.create(
            user=self.user,
            name=u'Test App',
            desc=u'Application for testing.',
            website=u'https://example.com',
            redirect_uri=u'https://example.com/oauth',
        )

        clients = OAuthClient.query.all()
        self.assertEqual(len(clients), 1)
        self.assertEqual(clients[0].name, u'Test App')

        self.assertEqual(len(clients[0].client_id), 20)
        self.assertEqual(len(clients[0].client_secret), 40)
예제 #8
0
    def test_create(self):
        self.assertEqual(OAuthClient.query.count(), 0)

        new_client = OAuthClient.create(
            user=self.user,
            name=u'Test App',
            desc=u'Application for testing.',
            website=u'https://example.com',
            redirect_uri=u'https://example.com/oauth',
        )

        clients = OAuthClient.query.all()
        self.assertEqual(len(clients), 1)
        self.assertEqual(clients[0].name, u'Test App')

        self.assertEqual(len(clients[0].client_id), 20)
        self.assertEqual(len(clients[0].client_secret), 40)
예제 #9
0
 def test_to_dict(self):
     oauth_client = OAuthClient.create(
         user=self.user,
         name=u'Test App',
         desc=u'Application for testing.',
         website=u'https://example.com',
         redirect_uri=u'https://example.com/oauth',
     )
     self.assertDictEqual(
         oauth_client.to_dict(), {
             'client_id': oauth_client.client_id,
             'client_secret': oauth_client.client_secret,
             'user_id': oauth_client.user_id,
             'name': oauth_client.name,
             'desc': oauth_client.desc,
             'website': oauth_client.website,
             'redirect_uri': oauth_client.redirect_uri,
         })
 def test_to_dict(self):
     oauth_client = OAuthClient.create(
         user=self.user,
         name=u'Test App',
         desc=u'Application for testing.',
         website=u'https://example.com',
         redirect_uri=u'https://example.com/oauth',
     )
     self.assertDictEqual(
         oauth_client.to_dict(),
         {
             'client_id': oauth_client.client_id,
             'client_secret': oauth_client.client_secret,
             'user_id': oauth_client.user_id,
             'name': oauth_client.name,
             'desc': oauth_client.desc,
             'website': oauth_client.website,
             'redirect_uri': oauth_client.redirect_uri,
         }
     )
    def test_update(self):
        oauth_client = OAuthClient.create(
            user=self.user,
            name=u'Test App',
            desc=u'Application for testing.',
            website=u'https://example.com',
            redirect_uri=u'https://example.com/oauth',
        )

        oauth_client.update(
            name=u'Updated App',
            desc=u'Completely new app for testing.',
            website=u'https://example.org',
            redirect_uri=u'https://example.org/oauth',
        )

        client = OAuthClient.query.all()[0]
        self.assertEqual(client.name, u'Updated App')
        self.assertEqual(client.desc, u'Completely new app for testing.')
        self.assertEqual(client.website, u'https://example.org')
        self.assertEqual(client.redirect_uri, u'https://example.org/oauth')
예제 #12
0
    def test_update(self):
        oauth_client = OAuthClient.create(
            user=self.user,
            name=u'Test App',
            desc=u'Application for testing.',
            website=u'https://example.com',
            redirect_uri=u'https://example.com/oauth',
        )

        oauth_client.update(
            name=u'Updated App',
            desc=u'Completely new app for testing.',
            website=u'https://example.org',
            redirect_uri=u'https://example.org/oauth',
        )

        client = OAuthClient.query.all()[0]
        self.assertEqual(client.name, u'Updated App')
        self.assertEqual(client.desc, u'Completely new app for testing.')
        self.assertEqual(client.website, u'https://example.org')
        self.assertEqual(client.redirect_uri, u'https://example.org/oauth')
예제 #13
0
 def create_dummy_application(self):
     return OAuthClient.create(user=self.user, **self.application)
 def create_dummy_application(self):
     return OAuthClient.create(user=self.user, **self.application)