Skip to content

Commit 752776b

Browse files
committed
Error handling and formatting fixes
- Formalize error numbers - Namespace VBA variables - Prefix private methods and variables - Update progress bar in installer - Styling and comment updates
1 parent 0251371 commit 752776b

22 files changed

+585
-354
lines changed

VBA-Web - Installer.xlsm

-11 KB
Binary file not shown.

authenticators/DigestAuthenticator.cls

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = False
1010
''
1111
' Digest Authenticator v2.0.6
12-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
12+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
1313
'
1414
' Custom IWebAuthenticator for Digest Authentication
1515
' http://en.wikipedia.org/wiki/Digest_access_authentication
@@ -95,7 +95,7 @@ End Sub
9595

9696
Private Sub IWebAuthenticator_AfterExecute(ByVal Client As WebClient, ByVal Request As WebRequest, ByRef Response As WebResponse)
9797
If Response.StatusCode = 401 And Not Me.IsAuthenticated Then
98-
WebHelpers.LogDebug "Extract Authenticate and retry 401 request " & Client.GetFullRequestUrl(Request), "Digest.AfterExecute"
98+
WebHelpers.LogDebug "Extract Authenticate and retry 401 request " & Client.GetFullUrl(Request), "Digest.AfterExecute"
9999
ExtractAuthenticateInformation Response
100100

101101
Request.AddHeader "Authorization", CreateHeader(Client, Request)
@@ -105,7 +105,7 @@ End Sub
105105

106106
Public Function CreateHeader(Client As WebClient, Request As WebRequest) As String
107107
Dim Uri As String
108-
Uri = WebHelpers.UrlParts(Client.GetFullRequestUrl(Request))("Path")
108+
Uri = WebHelpers.UrlParts(Client.GetFullUrl(Request))("Path")
109109

110110
CreateHeader = "Digest" & _
111111
" username=""" & Me.Username & """" & _
@@ -125,7 +125,7 @@ Public Function CalculateResponse(Client As WebClient, Request As WebRequest) As
125125
Dim HA1 As String
126126
Dim HA2 As String
127127
Dim Uri As String
128-
Uri = WebHelpers.UrlParts(Client.GetFullRequestUrl(Request))("Path")
128+
Uri = WebHelpers.UrlParts(Client.GetFullUrl(Request))("Path")
129129

130130
HA1 = CalculateHA1
131131
HA2 = CalculateHA2(WebHelpers.MethodToName(Request.Method), Uri)

authenticators/FacebookAuthenticator.cls

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = True
1010
''
1111
' Facebook Authenticator v2.0.6
12-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
12+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
1313
'
1414
' Custom IWebAuthenticator for Facebook OAuth
1515
'

authenticators/GoogleAuthenticator.cls

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = True
1010
''
1111
' Google Authenticator v2.0.6
12-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
12+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
1313
'
1414
' Custom IWebAuthenticator for "installed application" authentication for Google APIs
1515
'
@@ -43,7 +43,7 @@ Attribute VB_Exposed = True
4343
'
4444
' @implements: IWebAuthenticator v3.*
4545
46-
' @license: MIT (http://www.opensource.org/licenses/mit-license.php
46+
' @license: MIT (http://www.opensource.org/licenses/mit-license.php)
4747
'
4848
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
4949
Implements IWebAuthenticator

authenticators/OAuth1Authenticator.cls

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = True
1010
''
1111
' OAuth1 Authenticator v2.0.6
12-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
12+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
1313
'
1414
' Utilize OAuth1 authentication
1515
'
@@ -204,7 +204,7 @@ Public Function RequestUrl(Client As WebClient, Request As WebRequest) As String
204204
' Unless specified, URL scheme and authority MUST be lowercase and include the port number; http default port 80 and https default port 443 MUST be excluded.
205205

206206
Dim Parts As Dictionary
207-
Set Parts = WebHelpers.UrlParts(Client.GetFullRequestUrl(Request))
207+
Set Parts = WebHelpers.UrlParts(Client.GetFullUrl(Request))
208208

209209
' Url scheme and authority MUST be lowercase
210210
RequestUrl = LCase(Parts("Protocol") & "://" & Parts("Host"))
@@ -224,7 +224,7 @@ Public Function RequestParameters(Client As WebClient, Request As WebRequest) As
224224
' TODO Sort parameters by key then value
225225

226226
Dim Parts As Dictionary
227-
Set Parts = WebHelpers.UrlParts(Client.GetFullRequestUrl(Request))
227+
Set Parts = WebHelpers.UrlParts(Client.GetFullUrl(Request))
228228

229229
' Remove leading ?
230230
RequestParameters = Parts("Querystring")

authenticators/OAuth2Authenticator.cls

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = True
1010
''
1111
' OAuth2 Authenticator v2.0.6
12-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
12+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
1313
'
1414
' Utilize OAuth2 authentication
1515
' (Currently using client credentials flow only)
@@ -79,7 +79,7 @@ End Sub
7979
' --------------------------------------------- '
8080

8181
Private Sub IWebAuthenticator_BeforeExecute(ByVal Client As WebClient, ByRef Request As WebRequest)
82-
On Error GoTo ErrorHandling
82+
On Error GoTo web_ErrorHandling
8383
If (Me.Token = "" Or Not Me.CacheToken) And (Me.TokenUrl <> "" And Me.TokenKey <> "") Then
8484
' Get new token
8585
Dim Http As Object
@@ -115,7 +115,7 @@ Private Sub IWebAuthenticator_BeforeExecute(ByVal Client As WebClient, ByRef Req
115115
End If
116116
Call Request.AddHeader("Authorization", CreateHeader())
117117

118-
ErrorHandling:
118+
web_ErrorHandling:
119119

120120
If Not Http Is Nothing Then Set Http = Nothing
121121
If Not Response Is Nothing Then Set Response = Nothing

authenticators/TwitterAuthenticator.cls

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = False
1010
''
1111
' Twitter Authenticator v2.0.6
12-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
12+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
1313
'
1414
' Custom IWebAuthenticator for application-only authentication in Twitter's V1.1 REST API
1515
'
1616
' - https://dev.twitter.com/docs/auth/application-only-auth
17-
' - https://github.com/timhall/VBA-Web/wiki/Implementing-your-own-IWebAuthenticator
17+
' - https://github.com/VBA-tools/VBA-Web/wiki/Implementing-your-own-IWebAuthenticator
1818
'
1919
' @implements: IWebAuthenticator v3.*
2020

build/dev.vbs

+18-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ Sub Development
111111
"Options:" & vbNewLine & _
112112
"- import [src/auth/async/specs/auth-specs/async-specs] to [blank/specs/async-specs/example/all/path...]" & vbNewLine & _
113113
"- export [src/auth/async/specs/auth-specs/async-specs] from [blank/specs/async-specs/example/all/path...]" & vbNewLine & _
114-
"- release"
114+
"- release" & vbNewLine & _
115+
"- dev [specs/async-specs/example]"
115116

116117
Dim Action
117118
Action = Input(vbNewLine & "What would you like to do? <")
@@ -136,6 +137,22 @@ Sub Development
136137
Execute "import", "auth-specs", "specs"
137138
Execute "import", "async", "async-specs"
138139
Execute "import", "async-specs", "async-specs"
140+
ElseIf UCase(Parts(0)) = "DEV" Then
141+
If UCase(Parts(1)) = "SPECS" Then
142+
Execute "export", "src", "specs"
143+
Execute "export", "specs", "specs"
144+
Execute "export", "auth", "specs"
145+
Execute "export", "auth-specs", "specs"
146+
ElseIf UCase(Parts(1)) = "ASYNC-SPECS" Then
147+
Execute "export", "src", "async-specs"
148+
Execute "export", "async", "async-specs"
149+
Execute "export", "async-specs", "async-specs"
150+
ElseIf UCase(Parts(1)) = "EXAMPLE" Then
151+
Execute "export", "src", "example"
152+
Execute "export", "auth", "example"
153+
Else
154+
PrintLn vbNewLine & "Error: Unrecognized target for dev action"
155+
End If
139156
ElseIf UBound(Parts) < 3 Or (UCase(Parts(0)) <> "IMPORT" And UCase(Parts(0)) <> "EXPORT") Then
140157
PrintLn vbNewLine & "Error: Unrecognized action"
141158
Else

specs/Specs_DigestAuthenticator.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Attribute VB_Name = "Specs_DigestAuthenticator"
22
''
33
' Specs_DigestAuthenticator
4-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
4+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
55
'
66
' Specs for DigestAuthenticator
77
'

specs/Specs_GoogleAuthenticator.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Attribute VB_Name = "Specs_GoogleAuthenticator"
22
''
33
' Specs_GoogleAuthenticator
4-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
4+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
55
'
66
' Specs for GoogleAuthenticator
77
'

specs/Specs_IWebAuthenticator.bas

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Attribute VB_Name = "Specs_IWebAuthenticator"
22
''
33
' Specs_IWebAuthenticator
4-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
4+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
55
'
66
' Specs for IWebAuthenticator
77
'

specs/Specs_OAuth1Authenticator.bas

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Attribute VB_Name = "Specs_OAuth1Authenticator"
22
''
33
' Specs_OAuth1Authenticator
4-
' (c) Tim Hall - https://github.com/timhall/VBA-Web
4+
' (c) Tim Hall - https://github.com/VBA-tools/VBA-Web
55
'
66
' Specs for OAuth1Authenctiator
77
'
@@ -71,7 +71,7 @@ Public Function Specs() As SpecSuite
7171
Request.AddQuerystringParam "a", "a b"
7272

7373
.Expect(Auth.RequestParameters(Client, Request)).ToEqual "a=a%20b"
74-
.Expect(Client.GetFullRequestUrl(Request)).ToEqual "http://localhost:3000/testing?a=a+b"
74+
.Expect(Client.GetFullUrl(Request)).ToEqual "http://localhost:3000/testing?a=a+b"
7575
End With
7676

7777
Set Client = New WebClient

0 commit comments

Comments
 (0)