Skip to content

Commit 42e625e

Browse files
committed
updated unit tests with refresh_token which should not be present in brearer token file
Signed-off-by: Savvas Kyriacou <[email protected]>
1 parent 128e626 commit 42e625e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/auth/authLogin_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestLoginWithNoGalasactlPropertiesFileReturnsError(t *testing.T) {
4848
mockEnvironment := utils.NewMockEnv()
4949
mockGalasaHome, _ := utils.NewGalasaHome(mockFileSystem, mockEnvironment, "")
5050

51-
mockResponse := `{"jwt":"blah"}`
51+
mockResponse := `{"jwt":"blah", "refresh_token":"abc"}`
5252
server := NewAuthServletMock(t, 200, mockResponse)
5353
defer server.Close()
5454

@@ -71,7 +71,7 @@ func TestLoginWithBadGalasactlPropertiesFileReturnsError(t *testing.T) {
7171
galasactlPropertiesFilePath := mockGalasaHome.GetNativeFolderPath() + "/galasactl.properties"
7272
mockFileSystem.WriteTextFile(galasactlPropertiesFilePath, "here are some bad galasactl.properties contents!")
7373

74-
mockResponse := `{"jwt":"blah"}`
74+
mockResponse := `{"jwt":"blah", "refresh_token":"abc"}`
7575
server := NewAuthServletMock(t, 200, mockResponse)
7676
defer server.Close()
7777

@@ -98,7 +98,7 @@ func TestLoginCreatesBearerTokenFileContainingJWT(t *testing.T) {
9898
tokenPropertyValue := mockRefreshToken + TOKEN_SEPARATOR + mockClientId
9999
mockFileSystem.WriteTextFile(galasactlPropertiesFilePath, fmt.Sprintf("GALASA_TOKEN=%s", tokenPropertyValue))
100100

101-
mockResponse := `{"jwt":"blah"}`
101+
mockResponse := `{"jwt":"blah", "refresh_token":"abc"}`
102102
server := NewAuthServletMock(t, 200, mockResponse)
103103
defer server.Close()
104104

@@ -112,9 +112,10 @@ func TestLoginCreatesBearerTokenFileContainingJWT(t *testing.T) {
112112
bearerTokenFileContents, _ := mockFileSystem.ReadTextFile(bearerTokenFilePath)
113113

114114
// Then...
115+
expectedJson := `{"jwt":"blah"}`
115116
assert.Nil(t, err, "Should not return an error if the bearer token file has been successfully created")
116117
assert.True(t, bearerTokenFileExists, "Bearer token file should exist")
117-
assert.Equal(t, mockResponse, bearerTokenFileContents)
118+
assert.Equal(t, expectedJson, bearerTokenFileContents)
118119
}
119120

120121
func TestLoginWithFailedFileWriteReturnsError(t *testing.T) {
@@ -134,7 +135,7 @@ func TestLoginWithFailedFileWriteReturnsError(t *testing.T) {
134135
return errors.New("simulating a failed write operation")
135136
}
136137

137-
mockResponse := `{"jwt":"blah"}`
138+
mockResponse := `{"jwt":"blah", "refresh_token":"abc"}`
138139
server := NewAuthServletMock(t, 200, mockResponse)
139140
defer server.Close()
140141

@@ -185,7 +186,7 @@ func TestLoginWithMissingAuthPropertyReturnsError(t *testing.T) {
185186

186187
mockFileSystem.WriteTextFile(galasactlPropertiesFilePath, "unknown.value=blah")
187188

188-
mockResponse := `{"jwt":"blah"}`
189+
mockResponse := `{"jwt":"blah", "refresh_token":"abc"}`
189190
server := NewAuthServletMock(t, 200, mockResponse)
190191
defer server.Close()
191192

0 commit comments

Comments
 (0)