@@ -4,11 +4,13 @@ import (
44 "fmt"
55 "os"
66 "strings"
7+
8+ "github.com/authorizerdev/authorizer/server/constants"
79)
810
911// ClearStore clears the in-memory store.
1012func (c * provider ) ClearStore () error {
11- if os .Getenv ("ENV" ) != "test" {
13+ if os .Getenv ("ENV" ) != constants . TestEnv {
1214 c .mutex .Lock ()
1315 defer c .mutex .Unlock ()
1416 }
@@ -19,10 +21,6 @@ func (c *provider) ClearStore() error {
1921
2022// GetUserSessions returns all the user session token from the in-memory store.
2123func (c * provider ) GetUserSessions (userId string ) map [string ]string {
22- if os .Getenv ("ENV" ) != "test" {
23- c .mutex .Lock ()
24- defer c .mutex .Unlock ()
25- }
2624 res := map [string ]string {}
2725 for k , v := range c .stateStore {
2826 split := strings .Split (v , "@" )
@@ -36,7 +34,7 @@ func (c *provider) GetUserSessions(userId string) map[string]string {
3634
3735// DeleteAllUserSession deletes all the user sessions from in-memory store.
3836func (c * provider ) DeleteAllUserSession (userId string ) error {
39- if os .Getenv ("ENV" ) != "test" {
37+ if os .Getenv ("ENV" ) != constants . TestEnv {
4038 c .mutex .Lock ()
4139 defer c .mutex .Unlock ()
4240 }
@@ -50,7 +48,7 @@ func (c *provider) DeleteAllUserSession(userId string) error {
5048
5149// SetState sets the state in the in-memory store.
5250func (c * provider ) SetState (key , state string ) error {
53- if os .Getenv ("ENV" ) != "test" {
51+ if os .Getenv ("ENV" ) != constants . TestEnv {
5452 c .mutex .Lock ()
5553 defer c .mutex .Unlock ()
5654 }
@@ -61,11 +59,6 @@ func (c *provider) SetState(key, state string) error {
6159
6260// GetState gets the state from the in-memory store.
6361func (c * provider ) GetState (key string ) (string , error ) {
64- if os .Getenv ("ENV" ) != "test" {
65- c .mutex .Lock ()
66- defer c .mutex .Unlock ()
67- }
68-
6962 state := ""
7063 if stateVal , ok := c .stateStore [key ]; ok {
7164 state = stateVal
@@ -76,7 +69,7 @@ func (c *provider) GetState(key string) (string, error) {
7669
7770// RemoveState removes the state from the in-memory store.
7871func (c * provider ) RemoveState (key string ) error {
79- if os .Getenv ("ENV" ) != "test" {
72+ if os .Getenv ("ENV" ) != constants . TestEnv {
8073 c .mutex .Lock ()
8174 defer c .mutex .Unlock ()
8275 }
0 commit comments