github.com/uvalib/orcid-access-ws@v0.0.0-20250612130209-7d062dbabf9d/orcidaccessws/tests/get_attribs_test.go (about) 1 package test 2 3 import ( 4 "github.com/uvalib/orcid-access-ws/orcidaccessws/client" 5 "net/http" 6 "testing" 7 ) 8 9 // 10 // get ORCID attribute tests 11 // 12 13 func TestGetOrcidAttributesHappyDay(t *testing.T) { 14 15 expected := http.StatusOK 16 id := goodCid 17 status, attributes := client.GetOrcidAttributes(cfg.Endpoint, id, goodToken(cfg.Secret)) 18 if status != expected { 19 t.Fatalf("Expected %v, got %v\n", expected, status) 20 } 21 22 if attributes == nil || len(attributes) == 0 { 23 t.Fatalf("Expected to find orcid for %s and did not\n", id) 24 } 25 26 ensureValidOrcidsAttributes(t, attributes) 27 } 28 29 func TestGetOrcidAttributesEmptyId(t *testing.T) { 30 expected := http.StatusBadRequest 31 status, _ := client.GetOrcidAttributes(cfg.Endpoint, empty, goodToken(cfg.Secret)) 32 if status != expected { 33 t.Fatalf("Expected %v, got %v\n", expected, status) 34 } 35 } 36 37 func TestGetOrcidAttributesNotFoundId(t *testing.T) { 38 expected := http.StatusNotFound 39 status, _ := client.GetOrcidAttributes(cfg.Endpoint, badCid, goodToken(cfg.Secret)) 40 if status != expected { 41 t.Fatalf("Expected %v, got %v\n", expected, status) 42 } 43 } 44 45 func TestGetOrcidAttributesEmptyToken(t *testing.T) { 46 expected := http.StatusBadRequest 47 status, _ := client.GetOrcidAttributes(cfg.Endpoint, goodCid, empty) 48 if status != expected { 49 t.Fatalf("Expected %v, got %v\n", expected, status) 50 } 51 } 52 53 func TestGetOrcidAttributesBadToken(t *testing.T) { 54 expected := http.StatusForbidden 55 status, _ := client.GetOrcidAttributes(cfg.Endpoint, goodCid, badToken(cfg.Secret)) 56 if status != expected { 57 t.Fatalf("Expected %v, got %v\n", expected, status) 58 } 59 } 60 61 // 62 // end of file 63 //