Skip to content

Commit

Permalink
delete test which contains real token 🤡
Browse files Browse the repository at this point in the history
  • Loading branch information
denispopesku committed Sep 6, 2023
1 parent df39dd9 commit 147e336
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions core/validation_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,14 @@ import (
"testing"
)

func TestGetProjectByToken(t *testing.T) {
client := NewQodanaClient()
result := client.GetProjectByToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb24iOiIzb0RycCIsInByb2plY3QiOiJwbmRkcSIsInRva2VuIjoiM1BOb1YifQ.BzdJ3K5v-Hf27zsNlen19uhPjWzLFyyPxxQzCn3FvBg")
const projectName = "JS_LicenseAudit_Demo"
switch v := result.(type) {
case Success:
if v.Data["name"] != projectName {
t.Errorf("Expected project name %s, got %s", projectName, v.Data["name"])
}
case APIError:
if v.StatusCode != http.StatusForbidden {
t.Errorf("Expected status code %d, got %d", http.StatusForbidden, v.StatusCode)
}
case RequestError:
t.Errorf("Did not expect request error: %v", v)
}
}

func TestGetProjectByBadToken(t *testing.T) {
client := NewQodanaClient()
result := client.GetProjectByToken("https://tinyurl.com/SurpriseForYourMom")
switch v := result.(type) {
case Success:
t.Errorf("Did not expect request error: %v", v)
case APIError:
if v.StatusCode != http.StatusBadRequest {
if v.StatusCode > http.StatusBadRequest {
t.Errorf("Expected status code %d, got %d", http.StatusBadRequest, v.StatusCode)
}
case RequestError:
Expand All @@ -39,3 +21,10 @@ func TestGetProjectByBadToken(t *testing.T) {
t.Error("Unknown result type")
}
}

func TestValidateToken(t *testing.T) {
client := NewQodanaClient()
if projectName := client.validateToken("kek"); projectName != "" {
t.Errorf("Problem")
}
}

0 comments on commit 147e336

Please sign in to comment.