@@ -17,14 +17,14 @@ func testSetup() (a *Auth, s *mocks.MockStorer) {
1717 s = mocks .NewMockStorer ()
1818
1919 authboss .Cfg = authboss .NewConfig ()
20- authboss .Cfg .LogWriter = ioutil .Discard
21- authboss .Cfg .Layout = template .Must (template .New ("" ).Parse (`{{template "authboss" .}}` ))
22- authboss .Cfg .Storer = s
23- authboss .Cfg .XSRFName = "xsrf"
24- authboss .Cfg .XSRFMaker = func (_ http.ResponseWriter , _ * http.Request ) string {
20+ authboss .a .LogWriter = ioutil .Discard
21+ authboss .a .Layout = template .Must (template .New ("" ).Parse (`{{template "authboss" .}}` ))
22+ authboss .a .Storer = s
23+ authboss .a .XSRFName = "xsrf"
24+ authboss .a .XSRFMaker = func (_ http.ResponseWriter , _ * http.Request ) string {
2525 return "xsrfvalue"
2626 }
27- authboss .Cfg .PrimaryID = authboss .StoreUsername
27+ authboss .a .PrimaryID = authboss .StoreUsername
2828
2929 a = & Auth {}
3030 if err := a .Initialize (); err != nil {
@@ -51,8 +51,8 @@ func TestAuth(t *testing.T) {
5151 a , _ := testSetup ()
5252
5353 storage := a .Storage ()
54- if storage [authboss .Cfg .PrimaryID ] != authboss .String {
55- t .Error ("Expected storage KV:" , authboss .Cfg .PrimaryID , authboss .String )
54+ if storage [authboss .a .PrimaryID ] != authboss .String {
55+ t .Error ("Expected storage KV:" , authboss .a .PrimaryID , authboss .String )
5656 }
5757 if storage [authboss .StorePassword ] != authboss .String {
5858 t .Error ("Expected storage KV:" , authboss .StorePassword , authboss .String )
@@ -74,7 +74,7 @@ func TestAuth_loginHandlerFunc_GET_RedirectsWhenHalfAuthed(t *testing.T) {
7474 sessionStore .Put (authboss .SessionKey , "a" )
7575 sessionStore .Put (authboss .SessionHalfAuthKey , "false" )
7676
77- authboss .Cfg .AuthLoginOKPath = "/dashboard"
77+ authboss .a .AuthLoginOKPath = "/dashboard"
7878
7979 if err := a .loginHandlerFunc (ctx , w , r ); err != nil {
8080 t .Error ("Unexpeced error:" , err )
@@ -85,7 +85,7 @@ func TestAuth_loginHandlerFunc_GET_RedirectsWhenHalfAuthed(t *testing.T) {
8585 }
8686
8787 loc := w .Header ().Get ("Location" )
88- if loc != authboss .Cfg .AuthLoginOKPath {
88+ if loc != authboss .a .AuthLoginOKPath {
8989 t .Error ("Unexpected redirect:" , loc )
9090 }
9191}
@@ -106,7 +106,7 @@ func TestAuth_loginHandlerFunc_GET(t *testing.T) {
106106 if ! strings .Contains (body , "<form" ) {
107107 t .Error ("Should have rendered a form" )
108108 }
109- if ! strings .Contains (body , `name="` + authboss .Cfg .PrimaryID ) {
109+ if ! strings .Contains (body , `name="` + authboss .a .PrimaryID ) {
110110 t .Error ("Form should contain the primary ID field:" , body )
111111 }
112112 if ! strings .Contains (body , `name="password"` ) {
@@ -118,8 +118,8 @@ func TestAuth_loginHandlerFunc_POST_ReturnsErrorOnCallbackFailure(t *testing.T)
118118 a , storer := testSetup ()
119119 storer .Users ["john" ] = authboss.Attributes {"password" : "$2a$10$B7aydtqVF9V8RSNx3lCKB.l09jqLV/aMiVqQHajtL7sWGhCS9jlOu" }
120120
121- authboss .Cfg .Callbacks = authboss .NewCallbacks ()
122- authboss .Cfg .Callbacks .Before (authboss .EventAuth , func (_ * authboss.Context ) (authboss.Interrupt , error ) {
121+ authboss .a .Callbacks = authboss .NewCallbacks ()
122+ authboss .a .Callbacks .Before (authboss .EventAuth , func (_ * authboss.Context ) (authboss.Interrupt , error ) {
123123 return authboss .InterruptNone , errors .New ("explode" )
124124 })
125125
@@ -134,8 +134,8 @@ func TestAuth_loginHandlerFunc_POST_RedirectsWhenInterrupted(t *testing.T) {
134134 a , storer := testSetup ()
135135 storer .Users ["john" ] = authboss.Attributes {"password" : "$2a$10$B7aydtqVF9V8RSNx3lCKB.l09jqLV/aMiVqQHajtL7sWGhCS9jlOu" }
136136
137- authboss .Cfg .Callbacks = authboss .NewCallbacks ()
138- authboss .Cfg .Callbacks .Before (authboss .EventAuth , func (_ * authboss.Context ) (authboss.Interrupt , error ) {
137+ authboss .a .Callbacks = authboss .NewCallbacks ()
138+ authboss .a .Callbacks .Before (authboss .EventAuth , func (_ * authboss.Context ) (authboss.Interrupt , error ) {
139139 return authboss .InterruptAccountLocked , nil
140140 })
141141
@@ -150,7 +150,7 @@ func TestAuth_loginHandlerFunc_POST_RedirectsWhenInterrupted(t *testing.T) {
150150 }
151151
152152 loc := w .Header ().Get ("Location" )
153- if loc != authboss .Cfg .AuthLoginFailPath {
153+ if loc != authboss .a .AuthLoginFailPath {
154154 t .Error ("Unexpeced location:" , loc )
155155 }
156156
@@ -159,8 +159,8 @@ func TestAuth_loginHandlerFunc_POST_RedirectsWhenInterrupted(t *testing.T) {
159159 t .Error ("Expected error flash message:" , expectedMsg )
160160 }
161161
162- authboss .Cfg .Callbacks = authboss .NewCallbacks ()
163- authboss .Cfg .Callbacks .Before (authboss .EventAuth , func (_ * authboss.Context ) (authboss.Interrupt , error ) {
162+ authboss .a .Callbacks = authboss .NewCallbacks ()
163+ authboss .a .Callbacks .Before (authboss .EventAuth , func (_ * authboss.Context ) (authboss.Interrupt , error ) {
164164 return authboss .InterruptAccountNotConfirmed , nil
165165 })
166166
@@ -173,7 +173,7 @@ func TestAuth_loginHandlerFunc_POST_RedirectsWhenInterrupted(t *testing.T) {
173173 }
174174
175175 loc = w .Header ().Get ("Location" )
176- if loc != authboss .Cfg .AuthLoginFailPath {
176+ if loc != authboss .a .AuthLoginFailPath {
177177 t .Error ("Unexpeced location:" , loc )
178178 }
179179
@@ -224,9 +224,9 @@ func TestAuth_loginHandlerFunc_POST(t *testing.T) {
224224 ctx , w , r , _ := testRequest ("POST" , "username" , "john" , "password" , "1234" )
225225 cb := mocks .NewMockAfterCallback ()
226226
227- authboss .Cfg .Callbacks = authboss .NewCallbacks ()
228- authboss .Cfg .Callbacks .After (authboss .EventAuth , cb .Fn )
229- authboss .Cfg .AuthLoginOKPath = "/dashboard"
227+ authboss .a .Callbacks = authboss .NewCallbacks ()
228+ authboss .a .Callbacks .After (authboss .EventAuth , cb .Fn )
229+ authboss .a .AuthLoginOKPath = "/dashboard"
230230
231231 sessions := mocks .NewMockClientStorer ()
232232 ctx .SessionStorer = sessions
@@ -244,7 +244,7 @@ func TestAuth_loginHandlerFunc_POST(t *testing.T) {
244244 }
245245
246246 loc := w .Header ().Get ("Location" )
247- if loc != authboss .Cfg .AuthLoginOKPath {
247+ if loc != authboss .a .AuthLoginOKPath {
248248 t .Error ("Unexpeced location:" , loc )
249249 }
250250
@@ -283,7 +283,7 @@ func TestAuth_validateCredentials(t *testing.T) {
283283
284284 storer := mocks .NewMockStorer ()
285285 storer .GetErr = "Failed to load user"
286- authboss .Cfg .Storer = storer
286+ authboss .a .Storer = storer
287287
288288 ctx := authboss.Context {}
289289
@@ -305,7 +305,7 @@ func TestAuth_validateCredentials(t *testing.T) {
305305func TestAuth_logoutHandlerFunc_GET (t * testing.T ) {
306306 a , _ := testSetup ()
307307
308- authboss .Cfg .AuthLogoutOKPath = "/dashboard"
308+ authboss .a .AuthLogoutOKPath = "/dashboard"
309309
310310 ctx , w , r , sessionStorer := testRequest ("GET" )
311311 sessionStorer .Put (authboss .SessionKey , "asdf" )
0 commit comments