Logo Search packages:      
Sourcecode: ubuntu-sso-client version File versions  Download package

def ubuntu_sso::tests::test_main::Realm::test_realms (   self  ) 

Are realm URLs correctly retrieved from the config?

Definition at line 33 of file test_main.py.

00033                          :
        """Are realm URLs correctly retrieved from the config?"""
        # mock that tmp config file exists
        tmp_config_file = os.path.realpath(os.path.join(
          os.path.split(config.__file__)[0], "../../data/oauth_urls"
        ))
        osp = self.mocker.replace("os.path")
        osp.isfile(tmp_config_file)
        self.mocker.result(True)

        sio = StringIO.StringIO("""[default]
request_token_url = /rtu-default
user_authorisation_url = /uau-default
access_token_url = /atu-default
consumer_secret = foo-default

[http://localhost]
request_token_url = /rtu-localhost
user_authorisation_url = /uau-localhost
access_token_url = /atu-localhost
consumer_secret = foo-localhost

[http://ubuntuone.com]
request_token_url = /rtu-ubuntuone
user_authorisation_url = /uau-ubuntuone
access_token_url = /atu-ubuntuone
consumer_secret = foo-ubuntuone

""")
        mock_open = self.mocker.replace(open)
        mock_open(tmp_config_file)
        self.mocker.result(sio)

        self.mocker.replay()

        login = LoginProcessor(None, use_libnotify=False)

        # are localhost:XXXX URLs correctly fetched?
        (rtu, uau, atu, cs) = login.get_config_urls("http://localhost:9876")
        self.assertEqual(rtu, "http://localhost:9876/rtu-localhost")
        self.assertEqual(uau, "http://localhost:9876/uau-localhost")
        self.assertEqual(atu, "http://localhost:9876/atu-localhost")
        self.assertEqual(cs, "foo-localhost")

        # is a URL specifically in the config correctly fetched?
        (rtu, uau, atu, cs) = login.get_config_urls("http://ubuntuone.com")
        self.assertEqual(rtu, "http://ubuntuone.com/rtu-ubuntuone")
        self.assertEqual(uau, "http://ubuntuone.com/uau-ubuntuone")
        self.assertEqual(atu, "http://ubuntuone.com/atu-ubuntuone")
        self.assertEqual(cs, "foo-ubuntuone")

        # is a URL not in the config correctly fetched as default?
        (rtu, uau, atu, cs) = login.get_config_urls("http://other.example.net")
        self.assertEqual(rtu, "http://other.example.net/rtu-default")
        self.assertEqual(uau, "http://other.example.net/uau-default")
        self.assertEqual(atu, "http://other.example.net/atu-default")
        self.assertEqual(cs, "foo-default")




Generated by  Doxygen 1.6.0   Back to index