Esempio n. 1
0
    def test_get_token(self):
        body = ('{"User":{"Name":"username", '
                '"ServerId":"1efa5077976bfa92bc71652404f646ec",'
                '"Id":"2ec276a2642e54a19b612b9418a8bd3b","HasPassword":true,'
                '"HasConfiguredPassword":true,'
                '"HasConfiguredEasyPassword":false,'
                '"LastLoginDate":"2015-11-09T08:35:03.6357440Z",'
                '"LastActivityDate":"2015-11-09T08:35:03.6665060Z",'
                '"Configuration":{"AudioLanguagePreference":"",'
                '"PlayDefaultAudioTrack":true,"SubtitleLanguagePreference":"",'
                '"DisplayMissingEpisodes":false,'
                '"DisplayUnairedEpisodes":false,'
                '"GroupMoviesIntoBoxSets":false,'
                '"DisplayChannelsWithinViews":[],'
                '"ExcludeFoldersFromGrouping":[],"GroupedFolders":[],'
                '"SubtitleMode":"Default","DisplayCollectionsView":true,'
                '"DisplayFoldersView":false,"EnableLocalPassword":false,'
                '"OrderedViews":[],"IncludeTrailersInSuggestions":true,'
                '"EnableCinemaMode":true,"LatestItemsExcludes":[],'
                '"PlainFolderViews":[],"HidePlayedInLatest":true,'
                '"DisplayChannelsInline":false},'
                '"Policy":{"IsAdministrator":true,"IsHidden":false,'
                '"IsDisabled":false,"BlockedTags":[],'
                '"EnableUserPreferenceAccess":true,"AccessSchedules":[],'
                '"BlockUnratedItems":[],'
                '"EnableRemoteControlOfOtherUsers":false,'
                '"EnableSharedDeviceControl":true,'
                '"EnableLiveTvManagement":true,"EnableLiveTvAccess":true,'
                '"EnableMediaPlayback":true,'
                '"EnableAudioPlaybackTranscoding":true,'
                '"EnableVideoPlaybackTranscoding":true,'
                '"EnableContentDeletion":false,'
                '"EnableContentDownloading":true,"EnableSync":true,'
                '"EnableSyncTranscoding":true,"EnabledDevices":[],'
                '"EnableAllDevices":true,"EnabledChannels":[],'
                '"EnableAllChannels":true,"EnabledFolders":[],'
                '"EnableAllFolders":true,"InvalidLoginAttemptCount":0,'
                '"EnablePublicSharing":true}},'
                '"SessionInfo":{"SupportedCommands":[],'
                '"QueueableMediaTypes":[],"PlayableMediaTypes":[],'
                '"Id":"89f3b33f8b3a56af22088733ad1d76b3",'
                '"UserId":"2ec276a2642e54a19b612b9418a8bd3b",'
                '"UserName":"******","AdditionalUsers":[],'
                '"ApplicationVersion":"Unknown version",'
                '"Client":"Unknown app",'
                '"LastActivityDate":"2015-11-09T08:35:03.6665060Z",'
                '"DeviceName":"Unknown device","DeviceId":"Unknown device id",'
                '"SupportsRemoteControl":false,"PlayState":{"CanSeek":false,'
                '"IsPaused":false,"IsMuted":false,"RepeatMode":"RepeatNone"}},'
                '"AccessToken":"4b19180cf02748f7b95c7e8e76562fc8",'
                '"ServerId":"1efa5077976bfa92bc71652404f646ec"}')

        responses.add(responses.POST, ('http://localhost:8096'
                                       '/Users/AuthenticateByName'),
                      body=body,
                      status=200,
                      content_type='application/json')

        headers = {
            'Authorization': 'MediaBrowser',
            'UserId': 'e8837bc1-ad67-520e-8cd2-f629e3155721',
            'Client': 'other',
            'Device': 'empy',
            'DeviceId': 'beets',
            'Version': '0.0.0'
        }

        auth_data = {
            'username': '******',
            'password': '******',
            'passwordMd5': '5f4dcc3b5aa765d61d8327deb882cf99'
        }

        self.assertEqual(
            embyupdate.get_token('localhost', 8096, headers, auth_data),
            '4b19180cf02748f7b95c7e8e76562fc8')
Esempio n. 2
0
    def test_get_token(self):
        body = (
            '{"User":{"Name":"username", '
            '"ServerId":"1efa5077976bfa92bc71652404f646ec",'
            '"Id":"2ec276a2642e54a19b612b9418a8bd3b","HasPassword":true,'
            '"HasConfiguredPassword":true,'
            '"HasConfiguredEasyPassword":false,'
            '"LastLoginDate":"2015-11-09T08:35:03.6357440Z",'
            '"LastActivityDate":"2015-11-09T08:35:03.6665060Z",'
            '"Configuration":{"AudioLanguagePreference":"",'
            '"PlayDefaultAudioTrack":true,"SubtitleLanguagePreference":"",'
            '"DisplayMissingEpisodes":false,'
            '"DisplayUnairedEpisodes":false,'
            '"GroupMoviesIntoBoxSets":false,'
            '"DisplayChannelsWithinViews":[],'
            '"ExcludeFoldersFromGrouping":[],"GroupedFolders":[],'
            '"SubtitleMode":"Default","DisplayCollectionsView":true,'
            '"DisplayFoldersView":false,"EnableLocalPassword":false,'
            '"OrderedViews":[],"IncludeTrailersInSuggestions":true,'
            '"EnableCinemaMode":true,"LatestItemsExcludes":[],'
            '"PlainFolderViews":[],"HidePlayedInLatest":true,'
            '"DisplayChannelsInline":false},'
            '"Policy":{"IsAdministrator":true,"IsHidden":false,'
            '"IsDisabled":false,"BlockedTags":[],'
            '"EnableUserPreferenceAccess":true,"AccessSchedules":[],'
            '"BlockUnratedItems":[],'
            '"EnableRemoteControlOfOtherUsers":false,'
            '"EnableSharedDeviceControl":true,'
            '"EnableLiveTvManagement":true,"EnableLiveTvAccess":true,'
            '"EnableMediaPlayback":true,'
            '"EnableAudioPlaybackTranscoding":true,'
            '"EnableVideoPlaybackTranscoding":true,'
            '"EnableContentDeletion":false,'
            '"EnableContentDownloading":true,"EnableSync":true,'
            '"EnableSyncTranscoding":true,"EnabledDevices":[],'
            '"EnableAllDevices":true,"EnabledChannels":[],'
            '"EnableAllChannels":true,"EnabledFolders":[],'
            '"EnableAllFolders":true,"InvalidLoginAttemptCount":0,'
            '"EnablePublicSharing":true}},'
            '"SessionInfo":{"SupportedCommands":[],'
            '"QueueableMediaTypes":[],"PlayableMediaTypes":[],'
            '"Id":"89f3b33f8b3a56af22088733ad1d76b3",'
            '"UserId":"2ec276a2642e54a19b612b9418a8bd3b",'
            '"UserName":"******","AdditionalUsers":[],'
            '"ApplicationVersion":"Unknown version",'
            '"Client":"Unknown app",'
            '"LastActivityDate":"2015-11-09T08:35:03.6665060Z",'
            '"DeviceName":"Unknown device","DeviceId":"Unknown device id",'
            '"SupportsRemoteControl":false,"PlayState":{"CanSeek":false,'
            '"IsPaused":false,"IsMuted":false,"RepeatMode":"RepeatNone"}},'
            '"AccessToken":"4b19180cf02748f7b95c7e8e76562fc8",'
            '"ServerId":"1efa5077976bfa92bc71652404f646ec"}'
        )

        responses.add(
            responses.POST,
            ("http://localhost:8096" "/Users/AuthenticateByName"),
            body=body,
            status=200,
            content_type="application/json",
        )

        headers = {
            "Authorization": "MediaBrowser",
            "UserId": "e8837bc1-ad67-520e-8cd2-f629e3155721",
            "Client": "other",
            "Device": "empy",
            "DeviceId": "beets",
            "Version": "0.0.0",
        }

        auth_data = {
            "username": "******",
            "password": "******",
            "passwordMd5": "5f4dcc3b5aa765d61d8327deb882cf99",
        }

        self.assertEqual(
            embyupdate.get_token("localhost", 8096, headers, auth_data), "4b19180cf02748f7b95c7e8e76562fc8"
        )