Update Category and add complex object Jwt Test

This commit is contained in:
2019-01-01 14:08:08 -04:00
parent 75f31ec396
commit 7675c45992
3 changed files with 39 additions and 23 deletions

View File

@@ -20,6 +20,8 @@
<string>1.0</string> <string>1.0</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>

View File

@@ -224,7 +224,7 @@
<window key="window" title="Jot Token Inspector" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA"> <window key="window" title="Jot Token Inspector" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/> <rect key="contentRect" x="250" y="200" width="600" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/> <rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections> <connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/> <outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
@@ -236,24 +236,24 @@
</windowController> </windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/> <customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="75" y="250"/> <point key="canvasLocation" x="74" y="313"/>
</scene> </scene>
<!--Jwt Details View Controller--> <!--Jwt Details View Controller-->
<scene sceneID="hIz-AP-VOD"> <scene sceneID="hIz-AP-VOD">
<objects> <objects>
<viewController id="XfG-lQ-9wD" customClass="JwtDetailsViewController" customModule="Jot" customModuleProvider="target" sceneMemberID="viewController"> <viewController id="XfG-lQ-9wD" customClass="JwtDetailsViewController" customModule="Jot" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="m2S-Jp-Qdl"> <view key="view" wantsLayer="YES" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/> <rect key="frame" x="0.0" y="0.0" width="600" height="400"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dWm-hs-uGJ"> <scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dWm-hs-uGJ">
<rect key="frame" x="202" y="20" width="258" height="200"/> <rect key="frame" x="202" y="20" width="378" height="330"/>
<clipView key="contentView" id="fE7-t6-uzL"> <clipView key="contentView" id="fE7-t6-uzL">
<rect key="frame" x="1" y="0.0" width="256" height="199"/> <rect key="frame" x="1" y="0.0" width="376" height="329"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" headerView="RCc-he-ZlT" id="hMf-0E-Kx7"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" headerView="RCc-he-ZlT" id="hMf-0E-Kx7">
<rect key="frame" x="0.0" y="0.0" width="260" height="174"/> <rect key="frame" x="0.0" y="0.0" width="376" height="304"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/> <size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -272,7 +272,7 @@
</textFieldCell> </textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn> </tableColumn>
<tableColumn identifier="PayloadValue" width="136" minWidth="40" maxWidth="1000" id="ZcP-3I-0jy"> <tableColumn identifier="PayloadValue" width="252" minWidth="40" maxWidth="1000" id="ZcP-3I-0jy">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Payload Value"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Payload Value">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -289,8 +289,8 @@
</tableView> </tableView>
</subviews> </subviews>
</clipView> </clipView>
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="dRv-H9-0MR"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="dRv-H9-0MR">
<rect key="frame" x="1" y="183" width="256" height="16"/> <rect key="frame" x="1" y="313" width="376" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="bO0-T2-PhJ"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="bO0-T2-PhJ">
@@ -298,29 +298,29 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<tableHeaderView key="headerView" id="RCc-he-ZlT"> <tableHeaderView key="headerView" id="RCc-he-ZlT">
<rect key="frame" x="0.0" y="0.0" width="260" height="25"/> <rect key="frame" x="0.0" y="0.0" width="376" height="25"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</tableHeaderView> </tableHeaderView>
</scrollView> </scrollView>
<scrollView borderType="line" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="rwL-1l-Kbe"> <scrollView borderType="line" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="rwL-1l-Kbe">
<rect key="frame" x="20" y="52" width="163" height="198"/> <rect key="frame" x="20" y="52" width="163" height="328"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="NLv-aE-2I0"> <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="NLv-aE-2I0">
<rect key="frame" x="1" y="1" width="161" height="196"/> <rect key="frame" x="1" y="1" width="161" height="326"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="Xu4-Je-jSy"> <textView importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="Xu4-Je-jSy">
<rect key="frame" x="0.0" y="0.0" width="161" height="196"/> <rect key="frame" x="0.0" y="0.0" width="161" height="326"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="161" height="196"/> <size key="minSize" width="161" height="326"/>
<size key="maxSize" width="240" height="10000000"/> <size key="maxSize" width="240" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView> </textView>
</subviews> </subviews>
</clipView> </clipView>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="89o-3q-s9c"> <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="89o-3q-s9c">
<rect key="frame" x="146" y="1" width="16" height="196"/> <rect key="frame" x="146" y="1" width="16" height="326"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
</scrollView> </scrollView>
@@ -335,7 +335,7 @@
</connections> </connections>
</button> </button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XPr-JT-vJ5"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XPr-JT-vJ5">
<rect key="frame" x="202" y="233" width="67" height="17"/> <rect key="frame" x="202" y="363" width="67" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Algorithm:" id="onY-Rb-3lr"> <textFieldCell key="cell" lineBreakMode="clipping" title="Algorithm:" id="onY-Rb-3lr">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -343,7 +343,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ozd-8y-Hbf" userLabel="Algorithm Label"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ozd-8y-Hbf" userLabel="Algorithm Label">
<rect key="frame" x="273" y="233" width="37" height="17"/> <rect key="frame" x="273" y="363" width="37" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" placeholderString="None" id="ctx-LQ-4Tc"> <textFieldCell key="cell" lineBreakMode="clipping" placeholderString="None" id="ctx-LQ-4Tc">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -351,7 +351,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mzO-NU-UpT"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mzO-NU-UpT">
<rect key="frame" x="383" y="233" width="38" height="17"/> <rect key="frame" x="503" y="363" width="38" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Type:" id="hrz-Qa-N2Q"> <textFieldCell key="cell" lineBreakMode="clipping" title="Type:" id="hrz-Qa-N2Q">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -359,7 +359,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dnS-hC-tGI" userLabel="Type Label"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dnS-hC-tGI" userLabel="Type Label">
<rect key="frame" x="425" y="233" width="37" height="17"/> <rect key="frame" x="545" y="363" width="37" height="17"/>
<textFieldCell key="cell" lineBreakMode="clipping" placeholderString="None" id="CUX-5n-yuB"> <textFieldCell key="cell" lineBreakMode="clipping" placeholderString="None" id="CUX-5n-yuB">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -400,7 +400,7 @@
</viewController> </viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/> <customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="75" y="655"/> <point key="canvasLocation" x="74" y="885"/>
</scene> </scene>
</scenes> </scenes>
</document> </document>

View File

@@ -12,7 +12,7 @@ import XCTest
class JotTests: XCTestCase { class JotTests: XCTestCase {
func testJWTInit() { func testJWTInit() {
guard let jwt = JWT(token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqZ3JpZmZpbiIsIm5hbWUiOiJKYW1lcyBHcmlmZmluIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.DXfNW7Gzvie7LIl5-HSG9clm3sjeglYG2uNmsPvcNerBQbzLI06vys4YqqCMtrWKEFij_y2hKGP9YFdHSRMdtyVcGEXmYP6H6E62uGhASmGFzEHeSa6B1X1-v8lRt_YpIGEXhkUnxfhdcQ90HJlNfajv0ndnRFk8YJxRkmr99OI") else { guard let jwt = Jwt(token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqZ3JpZmZpbiIsIm5hbWUiOiJKYW1lcyBHcmlmZmluIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.DXfNW7Gzvie7LIl5-HSG9clm3sjeglYG2uNmsPvcNerBQbzLI06vys4YqqCMtrWKEFij_y2hKGP9YFdHSRMdtyVcGEXmYP6H6E62uGhASmGFzEHeSa6B1X1-v8lRt_YpIGEXhkUnxfhdcQ90HJlNfajv0ndnRFk8YJxRkmr99OI") else {
XCTFail() XCTFail()
return return
} }
@@ -22,14 +22,28 @@ class JotTests: XCTestCase {
} }
func testJWTPayload() { func testJWTPayload() {
guard let jwt = JWT(token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqZ3JpZmZpbiIsIm5hbWUiOiJKYW1lcyBHcmlmZmluIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.DXfNW7Gzvie7LIl5-HSG9clm3sjeglYG2uNmsPvcNerBQbzLI06vys4YqqCMtrWKEFij_y2hKGP9YFdHSRMdtyVcGEXmYP6H6E62uGhASmGFzEHeSa6B1X1-v8lRt_YpIGEXhkUnxfhdcQ90HJlNfajv0ndnRFk8YJxRkmr99OI") else { guard let jwt = Jwt(token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqZ3JpZmZpbiIsIm5hbWUiOiJKYW1lcyBHcmlmZmluIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.DXfNW7Gzvie7LIl5-HSG9clm3sjeglYG2uNmsPvcNerBQbzLI06vys4YqqCMtrWKEFij_y2hKGP9YFdHSRMdtyVcGEXmYP6H6E62uGhASmGFzEHeSa6B1X1-v8lRt_YpIGEXhkUnxfhdcQ90HJlNfajv0ndnRFk8YJxRkmr99OI") else {
XCTFail() XCTFail()
return return
} }
XCTAssertEqual(jwt.payload["sub"] as? String, "jgriffin") XCTAssertEqual(jwt.payload["sub"] as? String, "jgriffin")
XCTAssertEqual(jwt.payload["name"] as? String, "James Griffin") XCTAssertEqual(jwt.payload["name"] as? String, "James Griffin")
}
func testJwtPayloadWithComplexObject() {
guard let jwt = Jwt(token: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqZ3JpZmZpbiIsIm5hbWUiOiJKYW1lcyBHcmlmZmluIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMiwiZXhwIjoxNTY2MjM5MDIyLCJsaWMiOjIsInJvbGVzIjpbeyJ0eXBlIjoiQWRtaW4ifV19.W9xUEhfgQSZivmmcW_egcP3AR3QG7CTXo-1x-7NXgqdTxY9tDMcbVRvFuBj-qRcoh-Ugl-IHeQgSaUnxAfOwnHicWmRr5d44YO_MuuT7RYOPBImN2zg9CoYdrdIzbLkLo6m5muR5d8xs3lgRzhDneLCDKE4BfdDYqbMSkO4INWY") else {
XCTFail()
return
}
XCTAssertEqual(jwt.payload["exp"] as? Int, 1566239022)
guard let roles = jwt.payload["roles"] as? [[String:String]] else {
XCTFail()
return
}
XCTAssertEqual(roles.first!["type"], "Admin")
} }
} }