Skip to content

Commit dd75cf5

Browse files
committed
tests: enforcing default null for image and bio
1 parent add3ac7 commit dd75cf5

11 files changed

+275
-3
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
meta {
2+
name: Update user bio to empty string - should normalize to null
3+
type: http
4+
seq: 6
5+
}
6+
7+
put {
8+
url: {{host}}/api/user
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
body:json {
18+
{
19+
"user": {
20+
"bio": ""
21+
}
22+
}
23+
}
24+
25+
assert {
26+
res.status: eq 200
27+
}
28+
29+
script:post-response {
30+
expect(res.body.user.bio).to.be.null;
31+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
meta {
2+
name: Verify empty string normalization persisted
3+
type: http
4+
seq: 7
5+
}
6+
7+
get {
8+
url: {{host}}/api/user
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
assert {
18+
res.status: eq 200
19+
}
20+
21+
script:post-response {
22+
expect(res.body.user.bio).to.be.null;
23+
}

api/bruno/auth/08-restore-bio.bru

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
meta {
2+
name: Restore bio
3+
type: http
4+
seq: 8
5+
}
6+
7+
put {
8+
url: {{host}}/api/user
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
body:json {
18+
{
19+
"user": {
20+
"bio": "Updated bio"
21+
}
22+
}
23+
}
24+
25+
assert {
26+
res.status: eq 200
27+
}
28+
29+
script:post-response {
30+
expect(res.body.user.username).to.eql("auth_" + bru.getVar("uid"));
31+
expect(res.body.user.email).to.eql("auth_" + bru.getVar("uid") + "@test.com");
32+
expect(res.body.user.bio).to.eql("Updated bio");
33+
expect(res.body.user.image).to.be.null;
34+
expect(typeof res.body.user.token).to.eql("string");
35+
expect(res.body.user.token).to.not.eql("");
36+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
meta {
2+
name: Update user image
3+
type: http
4+
seq: 9
5+
}
6+
7+
put {
8+
url: {{host}}/api/user
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
body:json {
18+
{
19+
"user": {
20+
"image": "https://example.com/photo.jpg"
21+
}
22+
}
23+
}
24+
25+
assert {
26+
res.status: eq 200
27+
}
28+
29+
script:post-response {
30+
expect(res.body.user.image).to.eql("https://example.com/photo.jpg");
31+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
meta {
2+
name: Verify image update persisted
3+
type: http
4+
seq: 10
5+
}
6+
7+
get {
8+
url: {{host}}/api/user
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
assert {
18+
res.status: eq 200
19+
}
20+
21+
script:post-response {
22+
expect(res.body.user.image).to.eql("https://example.com/photo.jpg");
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
meta {
2+
name: Update image to empty string - should normalize to null
3+
type: http
4+
seq: 11
5+
}
6+
7+
put {
8+
url: {{host}}/api/user
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
body:json {
18+
{
19+
"user": {
20+
"image": ""
21+
}
22+
}
23+
}
24+
25+
assert {
26+
res.status: eq 200
27+
}
28+
29+
script:post-response {
30+
expect(res.body.user.image).to.be.null;
31+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
meta {
2+
name: Verify image empty string normalization persisted
3+
type: http
4+
seq: 12
5+
}
6+
7+
get {
8+
url: {{host}}/api/user
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: Token {{token}}
15+
}
16+
17+
assert {
18+
res.status: eq 200
19+
}
20+
21+
script:post-response {
22+
expect(res.body.user.image).to.be.null;
23+
}

api/bruno/auth/06-update-username-and-email.bru renamed to api/bruno/auth/13-update-username-and-email.bru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
meta {
22
name: Update username and email
33
type: http
4-
seq: 6
4+
seq: 13
55
}
66

77
put {

api/bruno/auth/07-verify-username-email-update-persisted.bru renamed to api/bruno/auth/14-verify-username-email-update-persisted.bru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
meta {
22
name: Verify username/email update persisted
33
type: http
4-
seq: 7
4+
seq: 14
55
}
66

77
get {

api/hurl/auth.hurl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,80 @@ jsonpath "$.user.image" == null
7878
jsonpath "$.user.token" isString
7979
jsonpath "$.user.token" not isEmpty
8080

81+
# Update user bio to empty string - should normalize to null
82+
PUT {{host}}/api/user
83+
Authorization: Token {{token}}
84+
{
85+
"user": {
86+
"bio": ""
87+
}
88+
}
89+
HTTP 200
90+
[Asserts]
91+
jsonpath "$.user.bio" == null
92+
93+
# Verify empty string normalization persisted
94+
GET {{host}}/api/user
95+
Authorization: Token {{token}}
96+
HTTP 200
97+
[Asserts]
98+
jsonpath "$.user.bio" == null
99+
100+
# Restore bio
101+
PUT {{host}}/api/user
102+
Authorization: Token {{token}}
103+
{
104+
"user": {
105+
"bio": "Updated bio"
106+
}
107+
}
108+
HTTP 200
109+
[Asserts]
110+
jsonpath "$.user.username" == "auth_{{uid}}"
111+
jsonpath "$.user.email" == "auth_{{uid}}@test.com"
112+
jsonpath "$.user.bio" == "Updated bio"
113+
jsonpath "$.user.image" == null
114+
jsonpath "$.user.token" isString
115+
jsonpath "$.user.token" not isEmpty
116+
117+
# Update user image
118+
PUT {{host}}/api/user
119+
Authorization: Token {{token}}
120+
{
121+
"user": {
122+
"image": "https://example.com/photo.jpg"
123+
}
124+
}
125+
HTTP 200
126+
[Asserts]
127+
jsonpath "$.user.image" == "https://example.com/photo.jpg"
128+
129+
# Verify image update persisted
130+
GET {{host}}/api/user
131+
Authorization: Token {{token}}
132+
HTTP 200
133+
[Asserts]
134+
jsonpath "$.user.image" == "https://example.com/photo.jpg"
135+
136+
# Update image to empty string - should normalize to null
137+
PUT {{host}}/api/user
138+
Authorization: Token {{token}}
139+
{
140+
"user": {
141+
"image": ""
142+
}
143+
}
144+
HTTP 200
145+
[Asserts]
146+
jsonpath "$.user.image" == null
147+
148+
# Verify image empty string normalization persisted
149+
GET {{host}}/api/user
150+
Authorization: Token {{token}}
151+
HTTP 200
152+
[Asserts]
153+
jsonpath "$.user.image" == null
154+
81155
# Update username and email
82156
PUT {{host}}/api/user
83157
Authorization: Token {{token}}

0 commit comments

Comments
 (0)