GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — qingcloud-sdk-python/tests/test_app_auth.py at master · Nan619/qingcloud-sdk-python

Expand file tree

/

test_app_auth.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
69 lines (55 loc) · 2.88 KB
/

test_app_auth.py

Copy path

File metadata and controls

69 lines (55 loc) · 2.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# =========================================================================
# Copyright 2012-present Yunify, Inc.
# -------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================================================================
import unittest
from qingcloud.conn.auth import AppSignatureAuthHandler
APP_ID = "app-zjd5o6ae"
APP_KEY = "CXikZWDoRkttCO8Y7XXhRTtMxiUFSr7ZePO1tGQP"
PAYLOAD = 'eyJhY2Nlc3NfdG9rZW4iOiIxMjM0NTY3IiwiYWN0aW9uIjoid\
mlld19hcHAiLCJleHBpcmVzIjoiMjAxNC0wMi0wOFQxMjowMDowMC4wMDBaIi\
wibGFuZyI6InpoX0NOIiwidXNlcl9pZCI6InVzZXItaWQxIiwiem9uZSI6ImJldGEifQ'
SIGNATURE = 'bwt9NTDknRpa3vu-gh_2u2qpKnlMBkrar8TeJwp6KG0'
ACCESS_INFO = {"user_id": "user-id1",
"access_token": "1234567",
"action": "view_app",
"zone": "beta",
"expires": "2014-02-08T12:00:00.000Z",
"lang": "zh_CN"}
class AppAuthTestCase(unittest.TestCase):
def setUp(self):
super(AppAuthTestCase, self).setUp()
self.app = AppSignatureAuthHandler(APP_ID, APP_KEY)
def test_sign_string(self):
self.assertEqual("-xmepZZrlRW9dOgO3KA9MY8rgOjLvfSedNEPXsxrpcQ",
self.app.sign_string("some string to sign"))
def test_extract_payload(self):
extracted_payload = self.app.extract_payload(
PAYLOAD,
SIGNATURE)
self.assertEqual(ACCESS_INFO, extracted_payload)
self.assertIsNone(self.app.extract_payload(
PAYLOAD,
"-xmepZZrlRW9dOgO3KA9MY8rgOjLvfSedNEPXsxrpcx"))
def test_create_auth(self):
auth_info = self.app.create_auth(ACCESS_INFO)
self.assertEqual(PAYLOAD, auth_info['payload'])
self.assertEqual(SIGNATURE,
auth_info['signature'])
def test_payload(self):
app = AppSignatureAuthHandler(
"app-b9p6qxqj", "jimLjavU3uQAGxrv6FkeJKd58ieRiuWeVtilFl7V")
extracted_payload = app.extract_payload("eyJsYW5nIjoiemgtY24iLCJ1c2VyX2lkIjoidXNyLWluZWE5dzdaIiwiem9uZSI6ImFsbGlub25lIiwiYWNjZXNzX3Rva2VuIjoiYWhacEhCOFZ2aUJ1bXB0YTBHeTZGMUFDUFNtbkZNeGsiLCJleHBpcmVzIjoiMjAxNS0wMS0yOFQwOTozNTozNFoiLCJhY3Rpb24iOiJ2aWV3X2FwcCJ9",
"3k-0pqvAjf5BvFtssV3_2t_KBkesEpYEmesv3O5sJeI")
self.assertIsNotNone(extracted_payload)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.