Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ func (r VerificationConfig) CaptchaScoreThreshold() float32 {
threshold := commonconfig.GetString(r.c.Captcha.ScoreThreshold, "")
thresholdFloat, err := strconv.ParseFloat(threshold, 32)
if err != nil {

if threshold != "" {
log.Error(nil, err, fmt.Sprintf("unable to parse captcha score threshold, using default value '%.1f'", defaultScoreThreshold))
}
Expand All @@ -288,7 +287,6 @@ func (r VerificationConfig) CaptchaRequiredScore() float32 {
threshold := commonconfig.GetString(r.c.Captcha.RequiredScore, "0")
thresholdFloat, err := strconv.ParseFloat(threshold, 32)
if err != nil {

if threshold != "" {
log.Error(nil, err, fmt.Sprintf("unable to parse automatic verification threshold, using default value '%.1f'", defaultAutomaticVerificationThreshold))
}
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/analytics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func (s *TestAnalyticsSuite) TestAnalyticsHandler() {
analyticsCtrl := NewAnalytics()

s.Run("valid devspaces segment write key json", func() {

// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
// pass 'nil' as the third parameter.
req, err := http.NewRequest(http.MethodGet, "/api/v1/segment-write-key", nil)
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/authconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (s *TestAuthConfigSuite) TestAuthClientConfigHandler() {
handler := gin.HandlerFunc(authConfigCtrl.GetHandler)

s.Run("valid json config", func() {

// We create a ResponseRecorder (which satisfies http.ResponseWriter) to record the response.
rr := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rr)
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func (s *Signup) InitVerificationHandler(ctx *gin.Context) {

// GetHandler returns the Signup resource
func (s *Signup) GetHandler(ctx *gin.Context) {

// Get the UserSignup resource from the service by the username
username := ctx.GetString(context.UsernameKey)
signupResource, err := s.app.SignupService().GetSignup(ctx, username, true)
Expand Down
3 changes: 0 additions & 3 deletions pkg/controller/signup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ func (s *TestSignupSuite) TestVerifyPhoneCodeHandler() {
})

s.Run("verifycode returns status error", func() {

userSignup.Annotations[crtapi.UserVerificationAttemptsAnnotationKey] = "9999"
userSignup.Annotations[crtapi.UserVerificationExpiryAnnotationKey] = time.Now().Add(10 * time.Second).Format(service.TimestampLayout)
userSignup.Annotations[crtapi.UserSignupVerificationTimestampAnnotationKey] = time.Now().Format(service.TimestampLayout)
Expand Down Expand Up @@ -569,7 +568,6 @@ func initPhoneVerification(t *testing.T, handler gin.HandlerFunc, params gin.Par
}

func (s *TestSignupSuite) TestVerifyActivationCodeHandler() {

s.Run("verification successful", func() {
// given
userSignup := testusersignup.NewUserSignup(testusersignup.VerificationRequiredAgo(time.Second)) // just signed up
Expand All @@ -592,7 +590,6 @@ func (s *TestSignupSuite) TestVerifyActivationCodeHandler() {
})

s.Run("verification failed", func() {

s.Run("too many attempts", func() {
// given
userSignup := testusersignup.NewUserSignup(
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller/usernames_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (s *TestUsernamesSuite) TestUsernamesGetHandler() {
)

s.Run("success", func() {

nsClient := namespaced.NewClient(fakeClient, commontest.HostOperatorNs)

// Create Usernames controller instance.
Expand Down Expand Up @@ -94,7 +93,6 @@ func (s *TestUsernamesSuite) TestUsernamesGetHandler() {
// Check the status code is what we expect.
assert.Equal(s.T(), http.StatusNotFound, rr.Code, "handler returned wrong status code")
})

})

s.Run("error", func() {
Expand Down
1 change: 0 additions & 1 deletion pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func Init(withName string, opts ...zap.Opts) {
}
klogv1.SetOutputBySeverity("INFO", klogWriter{}) // tell klog v1 to use the custom writer
// END : hack to redirect klogv1 calls to klog v2

})
}

Expand Down
1 change: 0 additions & 1 deletion pkg/middleware/jwt_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func (s *TestAuthMiddlewareSuite) TestAuthMiddlewareService() {
})

s.Run("auth requests", func() {

// do some requests
var authtests = []struct {
name string
Expand Down
6 changes: 0 additions & 6 deletions pkg/proxy/handlers/spacelister_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestSpaceListerGet(t *testing.T) {
}

func testSpaceListerGet(t *testing.T, publicViewerEnabled bool) {

memberFakeClient := test.NewFakeClient(t,
// spacebinding requests
spacebindingrequesttest.NewSpaceBindingRequest("animelover-sbr", "dancelover-dev",
Expand Down Expand Up @@ -608,7 +607,6 @@ func testSpaceListerGet(t *testing.T, publicViewerEnabled bool) {
}

func TestGetUserWorkspace(t *testing.T) {

fakeSignupService := fake.NewSignupService(
newSignup("batman", true),
newSignup("robin", true),
Expand Down Expand Up @@ -766,7 +764,6 @@ func TestGetUserWorkspace(t *testing.T) {
}

func TestSpaceListerGetPublicViewerEnabled(t *testing.T) {

fakeSignupService := fake.NewSignupService(
newSignup("batman", true),
newSignup("robin", true),
Expand Down Expand Up @@ -831,7 +828,6 @@ func TestSpaceListerGetPublicViewerEnabled(t *testing.T) {
}

for k, tc := range tests {

t.Run(k, func(t *testing.T) {
// given
signupProvider := fakeSignupService.GetSignup
Expand Down Expand Up @@ -869,7 +865,6 @@ func TestSpaceListerGetPublicViewerEnabled(t *testing.T) {
}

func TestGetUserWorkspaceWithBindingsWithPublicViewerEnabled(t *testing.T) {

fakeSignupService := fake.NewSignupService(
newSignup("batman", true),
newSignup("robin", true),
Expand Down Expand Up @@ -966,7 +961,6 @@ func TestGetUserWorkspaceWithBindingsWithPublicViewerEnabled(t *testing.T) {
}

for k, tc := range tests {

t.Run(k, func(t *testing.T) {
// given
signupProvider := fakeSignupService.GetSignup
Expand Down
1 change: 0 additions & 1 deletion pkg/proxy/handlers/spacelister_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func TestHandleSpaceListRequest(t *testing.T) {
}

for k, rtc := range tt {

t.Run(k, func(t *testing.T) {
// given
tests := map[string]struct {
Expand Down
1 change: 0 additions & 1 deletion pkg/proxy/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,4 @@ func (s *MemberClusters) getMemberURL(proxyPluginName string, member *cluster.Ca
scheme = "https://"
}
return url.Parse(scheme + proxyRoute.Status.Ingress[0].Host)

}
2 changes: 0 additions & 2 deletions pkg/proxy/members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func (s *TestMemberClustersSuite) TestGetClusterAccess() {
publicViewerEnabled := tc.publicViewerEnabled

s.Run(k, func() {

s.Run("unable to get signup", func() {
tt := map[string]struct {
workspace string
Expand Down Expand Up @@ -144,7 +143,6 @@ func (s *TestMemberClustersSuite) TestGetClusterAccess() {
// then
require.EqualError(s.T(), err, "user is not provisioned (yet)")
})

})
}
})
Expand Down
2 changes: 0 additions & 2 deletions pkg/proxy/metrics/proxy_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func TestHistogramVec(t *testing.T) {
require.Len(t, g[0].GetMetric()[3].GetLabel(), 2)
compareLabelPairValues(t, listFailure, g[0].GetMetric()[3].GetLabel())
require.Equal(t, uint64(2), g[0].GetMetric()[3].GetHistogram().GetSampleCount())

}

var expectedResponseMetadata = `
Expand Down Expand Up @@ -118,7 +117,6 @@ func createLabelPairs(name, value string) clientmodel.LabelPair {
}

func getExpectedLabelPairs() ([]clientmodel.LabelPair, []clientmodel.LabelPair, []clientmodel.LabelPair, []clientmodel.LabelPair) {

// labelPairs are ordered alphabetically on name when gathered.
getSuccess := []clientmodel.LabelPair{
createLabelPairs("kube_verb", "get"),
Expand Down
1 change: 0 additions & 1 deletion pkg/proxy/metrics_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func TestProxyMetricsServer(t *testing.T) {
_, err = buf.ReadFrom(resp.Body)
require.NoError(t, err)
assert.Equal(t, expectedServerBlankResponse, buf.String())

}

var expectedServerBlankResponse = `# HELP promhttp_metric_handler_errors_total Total number of internal errors encountered by the promhttp metric handler.
Expand Down
1 change: 0 additions & 1 deletion pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ func userHasBinding(username string, workspace *toolchainv1alpha1.Workspace) boo
}
}
return false

}

// getUserWorkspaceWithBindings retrieves the workspace with the SpaceBindings if the requesting user has access to it.
Expand Down
2 changes: 0 additions & 2 deletions pkg/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func (s *TestProxySuite) TestProxy() {

for _, environment := range []testconfig.EnvName{testconfig.E2E, testconfig.Dev, testconfig.Prod} {
s.Run("for environment "+string(environment), func() {

s.SetConfig(testconfig.RegistrationService().
Environment(string(environment)))

Expand Down Expand Up @@ -1181,7 +1180,6 @@ func (s *TestProxySuite) TestValidateWorkspaceRequest() {
}

func (s *TestProxySuite) TestGetTransport() {

s.Run("when not prod", func() {
for _, envName := range []testconfig.EnvName{testconfig.E2E, testconfig.Dev} {
s.Run("env "+string(envName), func() {
Expand Down
1 change: 0 additions & 1 deletion pkg/server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (srv *RegistrationServer) SetupRoutes(proxyPort string, reg *prometheus.Reg
err = errs.Wrap(err, "unable to setup route to serve static content")
}
srv.router.Use(static.Serve("/", staticHandler))

})
return err
}
1 change: 0 additions & 1 deletion pkg/server/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
)

func TestStaticContent(t *testing.T) {

log.Init("registration-service-testing")
router := gin.Default()
staticHandler, err := assets.ServeEmbedContent()
Expand Down
1 change: 0 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type RegistrationServer struct {

// New creates a new RegistrationServer object with reasonable defaults.
func New(application application.Application) *RegistrationServer {

gin.SetMode(gin.ReleaseMode)
ginRouter := gin.New()
ginRouter.Use(
Expand Down
2 changes: 0 additions & 2 deletions pkg/signup/service/signup_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, cl namespaced.Client, userna
// user's access token and updates the UserSignup if necessary. If updates were made, the function returns true
// otherwise it returns false.
func (s *ServiceImpl) auditUserSignupAgainstClaims(ctx *gin.Context, userSignup *toolchainv1alpha1.UserSignup) bool {

updated := false

updateIfRequired := func(ctx *gin.Context, key, existing string, updated bool) (string, bool) {
Expand Down Expand Up @@ -515,7 +514,6 @@ func GetDefaultUserTarget(cl namespaced.Client, spaceName, murName string) (stri
}
sort.Strings(spaceNames)
spaceName = spaceNames[0]

}
space := &toolchainv1alpha1.Space{}
if err := cl.Get(gocontext.TODO(), cl.NamespacedName(spaceName), space); err != nil {
Expand Down
9 changes: 0 additions & 9 deletions pkg/signup/service/signup_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func TestRunSignupServiceSuite(t *testing.T) {

func (s *TestSignupServiceSuite) ServiceConfiguration(verificationEnabled bool,
excludedDomains string, verificationCodeExpiresInMin int) {

s.OverrideApplicationDefault(
testconfig.RegistrationService().
Verification().Enabled(verificationEnabled).
Expand All @@ -67,7 +66,6 @@ func (s *TestSignupServiceSuite) TestSignup() {
// given
requestTime := time.Now()
assertUserSignupExists := func(cl client.Client, username string) toolchainv1alpha1.UserSignup {

userSignups := &toolchainv1alpha1.UserSignupList{}
err := cl.List(gocontext.TODO(), userSignups, client.InNamespace(commontest.HostOperatorNs))
require.NoError(s.T(), err)
Expand Down Expand Up @@ -182,7 +180,6 @@ func (s *TestSignupServiceSuite) TestSignup() {
})
}
func (s *TestSignupServiceSuite) TestSignupFailsWhenClientReturnsError() {

// given
rr := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rr)
Expand All @@ -205,7 +202,6 @@ func (s *TestSignupServiceSuite) TestSignupFailsWhenClientReturnsError() {
}

func (s *TestSignupServiceSuite) TestSignupFailsWithNotFoundThenOtherError() {

// given
rr := httptest.NewRecorder()
ctx, _ := gin.CreateTestContext(rr)
Expand Down Expand Up @@ -908,7 +904,6 @@ func (s *TestSignupServiceSuite) TestGetSignupReadyConditionStatus() {

for tcName, tc := range tests {
s.Run(tcName, func() {

// given
mur.Status = toolchainv1alpha1.MasterUserRecordStatus{
Conditions: []toolchainv1alpha1.Condition{
Expand Down Expand Up @@ -1021,7 +1016,6 @@ func (s *TestSignupServiceSuite) TestGetDefaultUserNamespaceMultiSpace() {
// then
assert.Equal(s.T(), "userB-dev", defaultUserNamespace) // space2 is prioritized over space1 because it was created by the userB
assert.Equal(s.T(), "member-123", targetCluster)

}

func (s *TestSignupServiceSuite) TestGetDefaultUserNamespaceFailNoHomeSpaceNoSpaceBinding() {
Expand Down Expand Up @@ -1167,13 +1161,10 @@ func (s *TestSignupServiceSuite) TestIsPhoneVerificationRequired() {
assert.InDelta(s.T(), float32(1.0), score, 0.01)
assert.Equal(s.T(), "captcha-assessment-123", assessmentID)
})

})

}

func (s *TestSignupServiceSuite) TestGetSignupUpdatesUserSignupIdentityClaims() {

s.ServiceConfiguration(false, "", 5)

// Create a new UserSignup
Expand Down
1 change: 0 additions & 1 deletion pkg/verification/sender/amazon_sns_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func NewAmazonSNSSender(cfg AWSSenderConfiguration) NotificationSender {
}

func (s *AmazonSNSSender) SendNotification(_ *gin.Context, content, phoneNumber, _ string) error {

// TODO add support for country-specific sender IDs if we ever decide to use Amazon SNS to send notifications

awsAccessKeyID := s.Config.AWSAccessKeyID()
Expand Down
1 change: 0 additions & 1 deletion pkg/verification/sender/twilio_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func (c *MockTwilioConfig) TwilioSenderConfigs() []toolchainv1alpha1.TwilioSende
}

func TestTwilioSenderID(t *testing.T) {

cfg := &MockTwilioConfig{
AccountSID: "TWILIO_SID_VALUE",
AuthToken: "AUTH_TOKEN_VALUE",
Expand Down
1 change: 0 additions & 1 deletion pkg/verification/service/verification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func generateVerificationCode() (string, error) {
// VerifyPhoneCode validates the user's phone verification code. It updates the specified UserSignup value, so even
// if an error is returned by this function the caller should still process changes to it
func (s *ServiceImpl) VerifyPhoneCode(ctx *gin.Context, username, code string) (verificationErr error) {

cfg := configuration.GetRegistrationServiceConfig()
// If we can't even find the UserSignup, then die here
signup := &toolchainv1alpha1.UserSignup{}
Expand Down
Loading