Exemplo n.º 1
0
func TestPasswordFromConfig(t *testing.T) {

	cfg := config.NewMockReader(
		config.MockString(func(path string) string {
			if path == userjwt.PathJWTPassword {
				return `Rump3lst!lzch3n`
			}
			return ""
		}),
	)

	jm, err := userjwt.New(
		userjwt.SetPasswordFromConfig(cfg),
	)
	assert.NoError(t, err)

	token, _, err := jm.GenerateToken(nil)
	assert.NoError(t, err)
	assert.NotEmpty(t, token)

}
Exemplo n.º 2
0
func TestSourceCurrencyAll(t *testing.T) {

	r := config.NewMockReader(
		config.MockString(func(path string) string {
			t.Log(path)
			switch path {
			case config.MockPathScopeStore(1, directory.PathDefaultLocale):
				return "de_CH"
			}
			return "Not Found"
		}),
	)

	s := config.ScopeID(1)

	sca := directory.NewSourceCurrencyAll(config.ModelConstructor{
		ConfigReader: r,
		Scope:        s,
	})

	t.Logf("\n%#v\n", sca.Options())

}
Exemplo n.º 3
0
			return 0
		case "stores/6023/system/smtp/port":
			return 4040
		default:
			return 0
		}
	}),
	config.MockString(func(path string) string {
		//		println("string", path)
		switch path {
		case "stores/5015/system/smtp/host":
			return ""
		case "stores/5015/system/smtp/username":
			return ""
		case "stores/6023/system/smtp/host":
			return "smtp.fastmail.com"
		case "stores/6023/system/smtp/username":
			return "2522e71a49e"
		case "stores/6023/system/smtp/password":
			return "9512e71a49f"
		default:
			return ""
		}

	}),
	config.MockBool(func(path string) bool {
		return false
	}),
)

func TestDialerPoolDefaultConfig(t *testing.T) {
	dm, err := NewDaemon(
Exemplo n.º 4
0
	"io"
	"testing"

	"github.com/corestoreio/csfw/config"
	"github.com/corestoreio/csfw/utils/mail"
	"github.com/go-gomail/gomail"
	"github.com/stretchr/testify/assert"
)

var configMock = config.NewMockReader(
	config.MockInt(func(path string) int {
		//println("int", path)
		return 25 // Port 25
	}),
	config.MockString(func(path string) string {
		//println("string", path)
		return "localhost"
	}),
	config.MockBool(func(path string) bool {
		//println("bool", path)
		switch path {
		case "stores/3001/system/smtp/disable":
			return true
		case "stores/4010/system/smtp/disable":
			return false
		default:
			return false
		}
	}),
)

type mockDial struct {
Exemplo n.º 5
0
func TestStoreBaseUrlandPath(t *testing.T) {

	s := store.NewStore(
		&store.TableStore{StoreID: 1, Code: dbr.NullString{NullString: sql.NullString{String: "de", Valid: true}}, WebsiteID: 1, GroupID: 1, Name: "Germany", SortOrder: 10, IsActive: true},
		&store.TableWebsite{WebsiteID: 1, Code: dbr.NullString{NullString: sql.NullString{String: "admin", Valid: true}}, Name: dbr.NullString{NullString: sql.NullString{String: "Admin", Valid: true}}, SortOrder: 0, DefaultGroupID: 0, IsDefault: dbr.NullBool{NullBool: sql.NullBool{Bool: false, Valid: true}}},
		&store.TableGroup{GroupID: 1, WebsiteID: 0, Name: "Default", RootCategoryID: 0, DefaultStoreID: 0},
	)

	tests := []struct {
		haveR        config.Reader
		haveUT       config.URLType
		haveIsSecure bool
		wantBaseUrl  string
		wantPath     string
	}{
		{
			config.NewMockReader(config.MockString(
				func(path string) string {
					switch path {
					case scope.StrDefault.FQPath("0", store.PathSecureBaseURL):
						return "https://corestore.io"
					case scope.StrDefault.FQPath("0", store.PathUnsecureBaseURL):
						return "http://corestore.io"
					}
					return ""
				},
			)),
			config.URLTypeWeb, true, "https://corestore.io/", "/",
		},
		{
			config.NewMockReader(config.MockString(
				func(path string) string {
					switch path {
					case scope.StrDefault.FQPath("0", store.PathSecureBaseURL):
						return "https://myplatform.io/customer1"
					case scope.StrDefault.FQPath("0", store.PathUnsecureBaseURL):
						return "http://myplatform.io/customer1"
					}
					return ""
				},
			)),
			config.URLTypeWeb, false, "http://myplatform.io/customer1/", "/customer1/",
		},
		{
			config.NewMockReader(config.MockString(
				func(path string) string {
					switch path {
					case scope.StrDefault.FQPath("0", store.PathSecureBaseURL):
						return store.PlaceholderBaseURL
					case scope.StrDefault.FQPath("0", store.PathUnsecureBaseURL):
						return store.PlaceholderBaseURL
					case scope.StrDefault.FQPath("0", config.PathCSBaseURL):
						return config.CSBaseURL
					}
					return ""
				},
			)),
			config.URLTypeWeb, false, config.CSBaseURL, "/",
		},
	}

	for _, test := range tests {
		s.ApplyOptions(store.SetStoreConfig(test.haveR))
		assert.EqualValues(t, test.wantBaseUrl, s.BaseURL(test.haveUT, test.haveIsSecure))
		assert.EqualValues(t, test.wantPath, s.Path())
	}
}