Ejemplo n.º 1
0
 def test_http_error(self):
     plugin = PDMLogin(arguments=[
         "--url", "http://numgen.app.corp:11108/prod_ng", "--cloneid",
         "17cu31oma", "--login", "csu", "--password", "P@ssw0rd"
     ])
     with self.assertRaises(PDMHttpError):
         plugin.login()
Ejemplo n.º 2
0
 def test_unauthorized_login(self):
     plugin = PDMLogin(arguments=[
         "--url", "http://numgen.app.corp:11105/prod_ng", "--cloneid",
         "17cu31oma", "--login", "csua", "--password", "P@ssw0rd"
     ])
     with self.assertRaises(PDMLoginFailed):
         plugin.login()
Ejemplo n.º 3
0
 def test_set_jsession_cookie(self):
     plugin = PDMLogin(arguments=[
         "--url", "http://numgen.app.corp:11105/prod_ng", "--cloneid",
         "17cu31omc", "--login", "csu", "--password", "P@ssw0rd"
     ])
     cookie = plugin._create_jsession_cookie()
     self.assertIn("JSESSIONID", cookie)
Ejemplo n.º 4
0
 def test_http_error(self):
     plugin = PDMLogin(
         arguments=["--url", "http://numgen.app.corp:11108/prod_ng",
                    "--cloneid", "17cu31oma",
                    "--login", "csu",
                    "--password", "P@ssw0rd"])
     with self.assertRaises(PDMHttpError):
         plugin.login()
Ejemplo n.º 5
0
 def test_unauthorized_login(self):
     plugin = PDMLogin(
         arguments=["--url", "http://numgen.app.corp:11105/prod_ng",
                    "--cloneid", "17cu31oma",
                    "--login", "csua",
                    "--password", "P@ssw0rd"])
     with self.assertRaises(PDMLoginFailed):
         plugin.login()
Ejemplo n.º 6
0
 def test_set_jsession_cookie(self):
     plugin = PDMLogin(
         arguments=["--url", "http://numgen.app.corp:11105/prod_ng",
                    "--cloneid", "17cu31omc",
                    "--login", "csu",
                    "--password", "P@ssw0rd"])
     cookie = plugin._create_jsession_cookie()
     self.assertIn("JSESSIONID", cookie)
Ejemplo n.º 7
0
 def test_bad_cloneid(self):
     plugin = PDMLogin(arguments=[
         "--url", "http://numgen.app.corp:11105/prod_ng", "--cloneid",
         "17cu31oma", "--login", "csu", "--password", "P@ssw0rd"
     ])
     plugin.login()
     cloneids = plugin.session.cookies["JSESSIONID"].split(":")[1:]
     self.assertEqual(2, len(cloneids))
Ejemplo n.º 8
0
 def test_bad_cloneid(self):
     plugin = PDMLogin(
         arguments=["--url", "http://numgen.app.corp:11105/prod_ng",
                    "--cloneid", "17cu31oma",
                    "--login", "csu",
                    "--password", "P@ssw0rd"])
     plugin.login()
     cloneids = plugin.session.cookies["JSESSIONID"].split(":")[1:]
     self.assertEqual(2, len(cloneids))
Ejemplo n.º 9
0
 def test_get_jsession_token(self):
     plugin = PDMLogin(arguments=[
         "--url", "http://numgen.app.corp:11105/prod_ng", "--cloneid",
         "17cu31omc", "--login", "csu", "--password", "P@ssw0rd"
     ])
     token = plugin.jsession_token
     self.assertRegexpMatches(token, r"^0{4}")
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#===============================================================================

import pdm
from pdm.plugin import PDMLogin
from pdm.exceptions import PDMHttpError, PDMLoginFailed


plugin = PDMLogin("Test login to PDM using HTTP on a specified node.",
                  version=pdm.VERSION)

# Main tests
try:
    plugin.login()
    jsessionid = plugin.session.cookies["JSESSIONID"].split(":")

    # jsessionid is the list composed of [token, bad_cloneid, good_cloneid]
    # It has 3 values instead of 2 when the cloneid specified from command line
    # cannot be reached.
    if len(jsessionid) > 2:
        print "CRITICAL - Login on node '{}' is not possible !".format(
            plugin.args.cloneid)
        raise SystemExit(2)
    else:
        print "OK - Login is successful on node '{}'.".format(
Ejemplo n.º 11
0
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#===============================================================================

import pdm
from pdm.plugin import PDMLogin
from pdm.exceptions import PDMHttpError, PDMLoginFailed

plugin = PDMLogin("Test login to PDM using HTTP on a specified node.",
                  version=pdm.VERSION)

# Main tests
try:
    plugin.login()
    jsessionid = plugin.session.cookies["JSESSIONID"].split(":")

    # jsessionid is the list composed of [token, bad_cloneid, good_cloneid]
    # It has 3 values instead of 2 when the cloneid specified from command line
    # cannot be reached.
    if len(jsessionid) > 2:
        print "CRITICAL - Login on node '{}' is not possible !".format(
            plugin.args.cloneid)
        raise SystemExit(2)
    else:
        print "OK - Login is successful on node '{}'.".format(