Skip to content

Commit dc89038

Browse files
Github Action failure fixes (#188)
* docs: update ask-smapi-sdk readme on using ASK-CLI util * fix: fixed the Github actions failures on test_verifier.py * fix: ask-local-debug code duplicates fixes and mypy upgrade config on tox Co-authored-by: Shreyas Govinda Raju <shreraju@amazon.com>
1 parent 90a8fd1 commit dc89038

File tree

7 files changed

+31
-54
lines changed

7 files changed

+31
-54
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ target/
7171
# mypy cache
7272
.mypy_cache/
7373

74+
# VSCode configs
75+
.vscode/

ask-sdk-local-debug/ask_sdk_local_debug/client/autobahn_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def invoke(self):
7979
"""
8080
try:
8181
connectWS(self.factory, contextFactory=None, timeout=CONNECTION_TIMEOUT_SECONDS)
82-
reactor.run()
82+
reactor.run() # type: ignore
8383
except Exception as e:
8484
logger.error(
8585
'Unable to initiate a socket client connection : {}'.format(

ask-sdk-local-debug/ask_sdk_local_debug/client/autobahn_client_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def onClose(self, was_clean, code, reason):
8989
:type reason: str or None
9090
"""
9191
logger.info("WebSocket connection closed: {} ".format(reason))
92-
reactor.stop()
92+
reactor.stop() # type: ignore
9393

9494
def send_skill_response(self, local_debug_ask_response):
9595
# type: (str) -> None

ask-sdk-local-debug/tests/unit/test_autobahn_client_protocol.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,11 @@
1515
# specific language governing permissions and limitations under the
1616
# License.
1717
#
18-
import unittest
1918
import json
20-
from mock import patch, Mock
19+
import unittest
2120

2221
from ask_sdk_local_debug.client.autobahn_client_protocol import AutobahnClientProtocol
23-
24-
TEST_REQUEST_DATA = ("{\n \"version\": \"fooversion\",\n"
25-
" \"type\": \"SkillRequestMessage\",\n"
26-
" \"requestId\": \"foorequestid\",\n"
27-
" \"requestPayload\": \"foorequestpayload\"\n}")
28-
29-
TEST_SUCCESS_RESPONSE = ("{\n \"version\": \"fooversion\",\n"
30-
" \"type\": \"SkillResponseSuccessMessage\",\n"
31-
" \"originalRequestId\": \"foorequestid\",\n"
32-
" \"responsePayload\": \"TestPayload\"\n}")
33-
34-
TEST_FAILURE_RESPONSE = ("{\n \"version\": \"fooversion\",\n"
35-
" \"type\": \"SkillResponseFailureMessage\",\n"
36-
" \"originalRequestId\": \"foorequestid\",\n"
37-
" \"errorCode\": \"500\",\n"
38-
" \"errorMessage\": \"mock error\"\n}")
39-
40-
TEST_DESERIALIZE_DATA = ("{\"version\": \"fooversion\", "
41-
"\"object_type\": \"SkillRequestMessage\", "
42-
"\"request_id\": \"foorequestid\", "
43-
"\"request_payload\": \"foorequestpayload\"}")
44-
45-
46-
def mock_skill_response(local_debug_request, skill_invoker):
47-
test_request = json.dumps(local_debug_request.to_dict())
48-
if test_request == TEST_DESERIALIZE_DATA:
49-
return TEST_SUCCESS_RESPONSE
50-
return TEST_FAILURE_RESPONSE
51-
22+
from mock import Mock, patch
5223

5324
TEST_REQUEST_DATA = ("{\n \"version\": \"fooversion\",\n"
5425
" \"type\": \"SkillRequestMessage\",\n"

ask-sdk-webservice-support/tests/unit/test_verifier.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,32 @@
1616
# License.
1717
#
1818
import base64
19-
import unittest
2019
import os
21-
import six
20+
import unittest
2221
import warnings
23-
2422
from datetime import datetime, timedelta
25-
from dateutil.tz import tzutc, tzlocal
26-
from six.moves.urllib.parse import ParseResult
23+
24+
import six
25+
from ask_sdk_model import IntentRequest, RequestEnvelope
26+
from ask_sdk_model.events.skillevents import SkillEnabledRequest
27+
from ask_sdk_webservice_support.verifier import (RequestVerifier,
28+
TimestampVerifier,
29+
VerificationException)
30+
from ask_sdk_webservice_support.verifier_constants import (
31+
CERT_CHAIN_DOMAIN, CHARACTER_ENCODING,
32+
MAX_NORMAL_REQUEST_TOLERANCE_IN_MILLIS,
33+
MAX_SKILL_EVENT_TOLERANCE_IN_MILLIS, SIGNATURE_CERT_CHAIN_URL_HEADER,
34+
SIGNATURE_HEADER)
35+
from cryptography import x509
2736
from cryptography.hazmat.backends import default_backend
2837
from cryptography.hazmat.primitives.asymmetric import rsa
29-
from cryptography.x509.oid import NameOID
30-
from cryptography import x509
31-
from cryptography.hazmat.primitives.hashes import SHA1
3238
from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15
33-
from ask_sdk_model import RequestEnvelope, IntentRequest
34-
from ask_sdk_model.events.skillevents import SkillEnabledRequest
35-
from ask_sdk_webservice_support.verifier import (
36-
RequestVerifier, TimestampVerifier, VerificationException)
37-
from ask_sdk_webservice_support.verifier_constants import (
38-
SIGNATURE_CERT_CHAIN_URL_HEADER, SIGNATURE_HEADER,
39-
CERT_CHAIN_DOMAIN, CHARACTER_ENCODING, MAX_NORMAL_REQUEST_TOLERANCE_IN_MILLIS,
40-
MAX_SKILL_EVENT_TOLERANCE_IN_MILLIS)
41-
from cryptography.x509 import load_pem_x509_certificate, Certificate
39+
from cryptography.hazmat.primitives.hashes import SHA1
40+
from cryptography.x509 import Certificate, load_pem_x509_certificate
41+
from cryptography.x509.oid import NameOID
42+
from dateutil.tz import tzlocal, tzutc
4243
from freezegun import freeze_time
44+
from six.moves.urllib.parse import ParseResult
4345

4446
try:
4547
import mock
@@ -96,8 +98,8 @@ def create_self_signed_certificate(self):
9698
number=x509.random_serial_number()).not_valid_before(
9799
time=datetime.utcnow() - timedelta(minutes=1)).not_valid_after(
98100
time=datetime.utcnow() + timedelta(minutes=1)).add_extension(
99-
extension=x509.SubjectAlternativeName(
100-
[x509.DNSName(u"{}".format(CERT_CHAIN_DOMAIN))]),
101+
x509.SubjectAlternativeName(
102+
[x509.DNSName(u"{}".format(CERT_CHAIN_DOMAIN))]),
101103
critical=False).sign(
102104
private_key=self.private_key,
103105
algorithm=SHA1(),

ask-smapi-sdk/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Generate Login with Amazon Keys
3737
- Create a new security profile for your Amazon Developer account by following the instructions
3838
provided `here <https://developer.amazon.com/en-US/docs/alexa/smapi/get-access-token-smapi.html#configure-lwa-security-profile>`__.
3939
- This will generate ``Client ID`` and ``Client Secret`` keys.
40-
- Using the ASK CLI, run: ``ask util generate-lwa-tokens``. You will be asked to provide the ``Client ID``
41-
and ``Client Secret`` keys from the previous step. This will return the following JSON with a ``Refresh Token``:
40+
- Using the ASK CLI v2, run: ``ask util generate-lwa-tokens --client_id <CLIENT_ID> ----client-confirmation <CLIENT_SECRET>``
41+
providing the ``Client ID`` and ``Client Secret`` keys from the previous step. This will return the following JSON with a ``Refresh Token``:
4242

4343
.. code-block:: json
4444

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ commands =
2828
flake8 .
2929
python -m pip install --upgrade pip
3030
python -m pip install --upgrade wheel
31+
py{36,37,38}: python -m pip install --upgrade mypy
3132
{toxinidir}/scripts/ci/sdk_install
3233
{toxinidir}/scripts/ci/run_tests
3334
py{36,37,38}: mypy ask-sdk/ask_sdk
@@ -55,6 +56,7 @@ commands =
5556
flake8 .
5657
python -m pip install --upgrade pip
5758
python -m pip install --upgrade wheel
59+
py{36,37,38}: python -m pip install --upgrade mypy
5860
python {toxinidir}\scripts\ci\sdk_install
5961
python {toxinidir}\scripts\ci\run_tests
6062
mypy ask-sdk\ask_sdk

0 commit comments

Comments
 (0)