Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[auth] Added new widget ui
- Loading branch information
Showing
6 changed files
with
132 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/auth/qgsauthenticationwidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsAuthenticationWidget : QWidget | ||
{ | ||
%Docstring | ||
Widget for entering authentication credentials both in the form username/password | ||
and by using QGIS Authentication Database and its authentication configurations. | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsauthenticationwidget.h" | ||
%End | ||
public: | ||
|
||
explicit QgsAuthenticationWidget( QWidget *parent /TransferThis/ = 0, const QString &dataprovider = QString() ); | ||
%Docstring | ||
Create a dialog for setting an associated authentication config, either | ||
from existing configs, or creating/removing them from auth database | ||
\param parent Parent widget | ||
\param dataprovider The key of the calling layer provider, if applicable | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/auth/qgsauthenticationwidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Tests for authentication widget | ||
From build dir, run from test directory: | ||
LC_ALL=en_US.UTF-8 ctest -R PyQgsAuthenticationWidget -V | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
import os | ||
import re | ||
import string | ||
import sys | ||
from shutil import rmtree | ||
import tempfile | ||
import random | ||
|
||
from qgis.core import QgsAuthManager, QgsAuthMethodConfig, QgsNetworkAccessManager, QgsSettings | ||
from qgis.gui import QgsAuthenticationWidget | ||
from qgis.testing import start_app, unittest | ||
|
||
from utilities import unitTestDataPath | ||
|
||
__author__ = 'Alessandro Pasotti' | ||
__date__ = '27/09/2017' | ||
__copyright__ = 'Copyright 2017, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
|
||
QGIS_AUTH_DB_DIR_PATH = tempfile.mkdtemp() | ||
|
||
os.environ['QGIS_AUTH_DB_DIR_PATH'] = QGIS_AUTH_DB_DIR_PATH | ||
|
||
qgis_app = start_app() | ||
|
||
|
||
class TestAuthenticationWidget(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Run before all tests: | ||
Creates an auth configuration""" | ||
# Enable auth | ||
# os.environ['QGIS_AUTH_PASSWORD_FILE'] = QGIS_AUTH_PASSWORD_FILE | ||
authm = QgsAuthManager.instance() | ||
assert (authm.setMasterPassword('masterpassword', True)) | ||
cls.auth_config = QgsAuthMethodConfig('Basic') | ||
cls.auth_config.setName('test_auth_config') | ||
cls.username = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) | ||
cls.password = cls.username[::-1] # reversed | ||
cls.auth_config.setConfig('username', cls.username) | ||
cls.auth_config.setConfig('password', cls.password) | ||
assert (authm.storeAuthenticationConfig(cls.auth_config)[0]) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
"""Run after all tests""" | ||
rmtree(QGIS_AUTH_DB_DIR_PATH) | ||
|
||
def setUp(self): | ||
"""Run before each test.""" | ||
pass | ||
|
||
def tearDown(self): | ||
"""Run after each test.""" | ||
pass | ||
|
||
def testWidget(self): | ||
""" | ||
Test the widget | ||
""" | ||
w = QgsAuthenticationWidget() | ||
w.show() | ||
from IPython import embed | ||
embed() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters