Skip to content

Commit

Permalink
fix(ot&e): url updated for OT&E environment
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Mar 23, 2022
1 parent 1e3b726 commit 4aed2be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ import (
// ISPAPI_CONNECTION_URL_PROXY represents the url used for the high performance connection setup
const ISPAPI_CONNECTION_URL_PROXY = "http://127.0.0.1/api/call.cgi"

// ISPAPI_CONNECTION_URL represents the url used for the default connection setup
const ISPAPI_CONNECTION_URL = "https://api.ispapi.net/api/call.cgi"
// ISPAPI_CONNECTION_URL_LIVE represents the url used for the default connection setup
const ISPAPI_CONNECTION_URL_LIVE = "https://api.ispapi.net/api/call.cgi"

// ISPAPI_CONNECTION_URL_OTE represents the url used for the OT&E (demo system) connection setup
const ISPAPI_CONNECTION_URL_OTE = "https://api-ote.ispapi.net/api/call.cgi"

var rtm = RTM.GetInstance()

Expand Down Expand Up @@ -62,7 +65,7 @@ func NewAPIClient() *APIClient {
cl := &APIClient{
debugMode: false,
socketTimeout: 300 * time.Second,
socketURL: ISPAPI_CONNECTION_URL,
socketURL: ISPAPI_CONNECTION_URL_LIVE,
socketConfig: SC.NewSocketConfig(),
curlopts: map[string]string{},
ua: "",
Expand Down Expand Up @@ -474,19 +477,21 @@ func (cl *APIClient) UseHighPerformanceConnectionSetup() *APIClient {

// UseDefaultConnectionSetup to activate default conneciton setup (the default anyways)
func (cl *APIClient) UseDefaultConnectionSetup() *APIClient {
cl.SetURL(ISPAPI_CONNECTION_URL)
cl.SetURL(ISPAPI_CONNECTION_URL_LIVE)
return cl
}

// UseOTESystem method to set OT&E System for API communication
func (cl *APIClient) UseOTESystem() *APIClient {
cl.SetURL(ISPAPI_CONNECTION_URL_OTE)
cl.socketConfig.SetSystemEntity("1234")
return cl
}

// UseLIVESystem method to set LIVE System for API communication
// Usage of LIVE System is active by default.
func (cl *APIClient) UseLIVESystem() *APIClient {
cl.SetURL(ISPAPI_CONNECTION_URL_LIVE)
cl.socketConfig.SetSystemEntity("54cd")
return cl
}
Expand Down
6 changes: 3 additions & 3 deletions apiclient/apiclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestGetSesssion2(t *testing.T) {

func TestGetURL(t *testing.T) {
url := cl.GetURL()
if strings.Compare(url, ISPAPI_CONNECTION_URL) != 0 {
if strings.Compare(url, ISPAPI_CONNECTION_URL_LIVE) != 0 {
t.Error("TestGetURL: Expected url not matching.")
}
}
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestSetURL(t *testing.T) {
if strings.Compare(ISPAPI_CONNECTION_URL_PROXY, url) != 0 {
t.Error("TestSetURL: Expected url not matching.")
}
cl.SetURL(ISPAPI_CONNECTION_URL)
cl.SetURL(ISPAPI_CONNECTION_URL_LIVE)
}

func TestSetOTP1(t *testing.T) {
Expand Down Expand Up @@ -334,7 +334,7 @@ func TestUseHighPerformanceConnectionSetup(t *testing.T) {
func TestDefaultConnectionSetup(t *testing.T) {
cl.UseDefaultConnectionSetup()
val := cl.GetURL()
if val != ISPAPI_CONNECTION_URL {
if val != ISPAPI_CONNECTION_URL_LIVE {
t.Error("TestDefaultConnectionSetup: couldn't activate default connection setup")
}
}
Expand Down

0 comments on commit 4aed2be

Please sign in to comment.