Example #1
0
    def test_url_equal(self):
        self.assertTrue(
            url_equal("http://test.com/test", "http://test.com/test"))
        self.assertFalse(
            url_equal("http://test.com/test", "http://test.com/test2"))

        self.assertTrue(
            url_equal("http://test.com/test",
                      "http://test.com/test2",
                      ignore_path=True))
        self.assertTrue(
            url_equal("http://test.com/test",
                      "https://test.com/test",
                      ignore_scheme=True))
        self.assertFalse(
            url_equal("http://test.com/test", "https://test.com/test"))

        self.assertTrue(
            url_equal("http://test.com/test",
                      "http://test.com/test#hello",
                      ignore_fragment=True))
        self.assertTrue(
            url_equal("http://test.com/test",
                      "http://test2.com/test",
                      ignore_netloc=True))
        self.assertFalse(
            url_equal("http://test.com/test",
                      "http://test2.com/test1",
                      ignore_netloc=True))
Example #2
0
    def test_url_equal(self):
        self.assertTrue(url_equal("http://test.com/test", "http://test.com/test"))
        self.assertFalse(url_equal("http://test.com/test", "http://test.com/test2"))

        self.assertTrue(url_equal("http://test.com/test", "http://test.com/test2", ignore_path=True))
        self.assertTrue(url_equal("http://test.com/test", "https://test.com/test", ignore_scheme=True))
        self.assertFalse(url_equal("http://test.com/test", "https://test.com/test"))

        self.assertTrue(url_equal("http://test.com/test", "http://test.com/test#hello", ignore_fragment=True))
        self.assertTrue(url_equal("http://test.com/test", "http://test2.com/test", ignore_netloc=True))
        self.assertFalse(url_equal("http://test.com/test", "http://test2.com/test1", ignore_netloc=True))
Example #3
0
    def login(self, username, password):
        self.logger.debug("Logging in as {0}".format(username))

        redirect_to = "https://home.bt.com/ss/Satellite/secure/loginforward?redirectURL={0}".format(
            quote(self.url))
        data = {
            "cookieExpp": "30",
            "Switch": "yes",
            "SMPostLoginUrl": "/appsyouraccount/secure/postlogin",
            "loginforward":
            "https://home.bt.com/ss/Satellite/secure/loginforward",
            "smauthreason": "0",
            "TARGET": redirect_to,
            "USER": username,
            "PASSWORD": password
        }

        res = self.session.http.post(self.login_url, data=data)

        self.logger.debug("Redirected to: {0}".format(res.url))

        if url_equal(res.url, self.url, ignore_scheme=True):
            self.logger.debug("Login successful, getting SAML token")
            res = self.session.http.get(
                "https://samlfed.bt.com/sportgetfedwebhls?bt.cid={0}".format(
                    self.acid()))
            d = self.saml_re.search(res.text)
            if d:
                saml_data = d.group(1)
                self.logger.debug("BT Sports federated login...")
                res = self.session.http.post(self.api_url,
                                             params={
                                                 "action": "LoginBT",
                                                 "channel": "WEBHLS",
                                                 "bt.cid": self.acid
                                             },
                                             data={"SAMLResponse": saml_data})
                fed_json = self.session.http.json(res)
                success = fed_json['resultCode'] == "OK"
                if not success:
                    self.logger.error("Failed to login: {0} - {1}".format(
                        fed_json['errorDescription'], fed_json['message']))
                return success
        return False
Example #4
0
    def login(self, username, password):
        self.logger.debug("Logging in as {0}".format(username))

        redirect_to = "https://home.bt.com/ss/Satellite/secure/loginforward?redirectURL={0}".format(quote(self.url))
        data = {
            "cookieExpp": "30",
            "Switch": "yes",
            "SMPostLoginUrl": "/appsyouraccount/secure/postlogin",
            "loginforward": "https://home.bt.com/ss/Satellite/secure/loginforward",
            "smauthreason": "0",
            "TARGET": redirect_to,
            "USER": username,
            "PASSWORD": password}

        res = http.post(self.login_url, data=data)

        self.logger.debug("Redirected to: {0}".format(res.url))


        if url_equal(res.url, self.url, ignore_scheme=True):
            self.logger.debug("Login successful, getting SAML token")
            res = http.get("https://samlfed.bt.com/sportgetfedwebhls?bt.cid={0}".format(self.acid()))
            d = self.saml_re.search(res.text)
            if d:
                saml_data = d.group(1)
                self.logger.debug("BT Sports federated login...")
                res = http.post(self.api_url,
                                params={"action": "LoginBT", "channel": "WEBHLS", "bt.cid": self.acid},
                                data={"SAMLResponse": saml_data})
                fed_json = http.json(res)
                success = fed_json['resultCode'] == "OK"
                if not success:
                    self.logger.error("Failed to login: {0} - {1}".format(fed_json['errorDescription'],
                                                                          fed_json['message']))
                return success
        return False