How to use base64Decode method in localstack

Best Python code snippet using localstack_python

Base64Decode.py

Source:Base64Decode.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2###############################################################################3#4# Base64Decode5# Returns the specified Base64 encoded string as decoded text.6#7# Python versions 2.6, 2.7, 3.x8#9# Copyright 2014, Temboo Inc.10#11# Licensed under the Apache License, Version 2.0 (the "License");12# you may not use this file except in compliance with the License.13# You may obtain a copy of the License at14#15# http://www.apache.org/licenses/LICENSE-2.016#17# Unless required by applicable law or agreed to in writing,18# software distributed under the License is distributed on an19# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,20# either express or implied. See the License for the specific21# language governing permissions and limitations under the License.22#23#24###############################################################################25from temboo.core.choreography import Choreography26from temboo.core.choreography import InputSet27from temboo.core.choreography import ResultSet28from temboo.core.choreography import ChoreographyExecution29import json30class Base64Decode(Choreography):31 def __init__(self, temboo_session):32 """33 Create a new instance of the Base64Decode Choreo. A TembooSession object, containing a valid34 set of Temboo credentials, must be supplied.35 """36 super(Base64Decode, self).__init__(temboo_session, '/Library/Utilities/Encoding/Base64Decode')37 def new_input_set(self):38 return Base64DecodeInputSet()39 def _make_result_set(self, result, path):40 return Base64DecodeResultSet(result, path)41 def _make_execution(self, session, exec_id, path):42 return Base64DecodeChoreographyExecution(session, exec_id, path)43class Base64DecodeInputSet(InputSet):44 """45 An InputSet with methods appropriate for specifying the inputs to the Base64Decode46 Choreo. The InputSet object is used to specify input parameters when executing this Choreo.47 """48 def set_Base64EncodedText(self, value):49 """50 Set the value of the Base64EncodedText input for this Choreo. ((required, string) The Base64 encoded text to decode. Note that Base64 encoded binary data is not allowed.)51 """52 super(Base64DecodeInputSet, self)._set_input('Base64EncodedText', value)53class Base64DecodeResultSet(ResultSet):54 """55 A ResultSet with methods tailored to the values returned by the Base64Decode Choreo.56 The ResultSet object is used to retrieve the results of a Choreo execution.57 """58 def getJSONFromString(self, str):59 return json.loads(str)60 def get_Text(self):61 """62 Retrieve the value for the "Text" output from this Choreo execution. ((string) The decoded text.)63 """64 return self._output.get('Text', None)65class Base64DecodeChoreographyExecution(ChoreographyExecution):66 def _make_result_set(self, response, path):...

Full Screen

Full Screen

test_encoding.py

Source:test_encoding.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2from tests.helpers import *3from CTFd.utils.encoding import base64encode, base64decode, hexdecode, hexencode4import string5import six6def test_hexencode():7 value = '303132333435363738396162636465666768696a6b6c6d6e6f7071727374757677' \8 '78797a4142434445464748494a4b4c4d4e4f505152535455565758595a21222324' \9 '25262728292a2b2c2d2e2f3a3b3c3d3e3f405b5c5d5e5f607b7c7d7e20090a0d0b0c'10 if six.PY3:11 value = value.encode('utf-8')12 assert hexencode(string.printable) == value13def test_hexdecode():14 saved = '303132333435363738396162636465666768696a6b6c6d6e6f7071727374757677' \15 '78797a4142434445464748494a4b4c4d4e4f505152535455565758595a21222324' \16 '25262728292a2b2c2d2e2f3a3b3c3d3e3f405b5c5d5e5f607b7c7d7e20090a0d0b0c'17 assert hexdecode(saved) == string.printable.encode('utf-8')18def test_base64encode():19 """The base64encode wrapper works properly"""20 if six.PY2:21 assert base64encode('abc123') == 'YWJjMTIz'22 assert base64encode(unicode('abc123')) == 'YWJjMTIz'23 assert base64encode(unicode('"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4')24 ) == 'InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ'25 assert base64encode('user+user@ctfd.io') == 'dXNlcit1c2VyQGN0ZmQuaW8'26 assert base64encode('😆') == '8J-Yhg'27 else:28 assert base64encode('abc123') == 'YWJjMTIz'29 assert base64encode(30 '"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4') == 'InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ'31 assert base64encode('user+user@ctfd.io') == 'dXNlcit1c2VyQGN0ZmQuaW8'32 assert base64encode('😆') == '8J-Yhg'33def test_base64decode():34 """The base64decode wrapper works properly"""35 if six.PY2:36 assert base64decode('YWJjMTIz') == 'abc123'37 assert base64decode(unicode('YWJjMTIz')) == 'abc123'38 assert base64decode(unicode('InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ')39 ) == '"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4'40 assert base64decode('8J-Yhg') == '😆'41 else:42 assert base64decode('YWJjMTIz') == 'abc123'43 assert base64decode(44 'InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ') == '"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4'45 assert base64decode('dXNlcit1c2VyQGN0ZmQuaW8') == 'user+user@ctfd.io'...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful