API  T E S T     A U T OM A TION DEE D I V E   I N T O   P R O T O C O L S T A C K API  TEST     AUT OMA TION DEEP  DIVE  INT PR O T OC OL ST A CK
About  An t on  Se me nche nk o Co - f ounder  \ a ct i vis of  C OM A QA .B Y ,   Co r eHa r d.B Y an In t erIT c omm uni ti es,   c o - f ounder  of  DP I.S ol uti ons ,   manager at  EP AM S ys t em s.  Mor e than  16  year s of  e xper i enc e in   IT Speci al i z es  i l o w - l e vel  de velopme n t,  Q A aut omati on,   managem en t,  sal es.
A g e n d a 3 1 OSI   Mod el T oo ls 3 W e se rvice   te stin g 2
A P P LI C A T I ON P R E S EN T A T I ON O S I m o d e l 4 S E S S I ON 4 T R A N S P OR T 3 N E T W OR K D A T A LINK 1 P H Y S I C A L D AT A S E G ME N T     P A C K E T     FRAME   B I T S PO R   I P    M A C
7   la y er  OSI  model : 1. I t   i s not  s t r i ct r epr ese n t a t i on  of  act ua l   ar chite ctur e,   but  r a t her   c oncep tion th a help s t o unde r s t and i n t er acti on  o v er   th ne tw or k .   I  beli e v e al mos t  al l   of  y ou  al r eady  sa t hi mode l or   a t   l eas t   hear ab out  it .   OSI  s t an ds  f or   Open  S y s t em   I n t er c onnecti on
7   la y er  OSI  model : 2. The fir s la y er is  th p h y sical  la y er .   Th i i h o d o   d e vic es  c o n n ec t Ar th e c onnec ti ng a cr oss  wir es Or   m a ybe  wit h fi ber ? 3. The sec o n d   la y er  up h er i s r e f er r ed  t o as t he  Da t aLink La y er .   Th Da t aL i nk l a y er   i den t i f i es  h o th e el ec tr o n ic signal should  b tr ansla t ed .  I s it   E t her ne t   or   wir eless.   I t   c oul d be 8 0 2 . 1 1   f or   wir eless  or   8 0 2 . 3   f or   E t her ne t   s t an da r ds.   Da t aL i nk l a y er   i sa ying   h o w th b its of  d a t a ar e p ac k ag ed . 4. The th ir d   le v el  up h er i t he  n e tw o rk  la y er .   T he n e t w ork   l a y er  i wher w i n t r oduce  t he c once p t   of  ad dr essing .   Fr o add r ess,  and   t o  add r ess 5. Th ese fir s th r ee  la y er ar de fi ned unde r   th OSI  m ode t o be   c o n tr o ll ed  b th n e tw o rk .  The ne x t  f our  ar t he s y s t em  or   soft w ar c on t r oll ed  c omponen t s.
7   la y er  OSI  model : 6. La y er n u mb er  f our  i c al l ed  t he  T r ansp o rt  La y er .  T r an sport  i s t ell i ng   us ho w ar g oing   t p ac k ag e th d a t b ec aus w e d on't   sen d   al o th c o n t en a t one time .   W send   it  in p ac k e ts .  The ar smal l   pi ec es  of  da t t ha t   ar t ak en  f r om  l ar g e bund l e of da t on  t he s y s t em  her … a nd  chopped  i n t smal l er   pi ec es. … .   an t hen  sen t  acr oss  t he in t er ne t   an r eassem bl ed  a t  th e f ar  si de.   So  tr anspor m ec hani sm s disassem bl th es pi ec es se nd  it   acr oss  th i n t er ne t  an d r eassem bl i t   a t  th e other   si de.   T r an sport  La y er   i v ery  i mpor t an t  f or   r eli ab i l i t of t he  da t a.   I t   ensur t ha t   I   act ua l l g e t  al l   of  t he me ssage .  I f   I  g e t  pa r t   of t he  me ssage   f r om  one  sour ce   an part f r om   anot her if   I  c an  pr ope r ly  put  them  back  t og e th er I  ha v t he c omple t me ssage .  The t r an sport  t ell me ho I   br eak   do wn  an put  ba ck  t og e t her   t he  da t a.  
7   la y er  OSI  model : 7. Ne x t   l e v el up  her i s Session.   This  is  wh er sessio n ar e han d led .   I t   open s,   cl ose, an d   able t o r ec ov er  a session .   And  it   al lo w t s ynchr oni z i n f or ma t i on  f r om  di f f er en t  s t r eams.  8. Al l   r i gh t so  one  l a y er   up  i la y er  6   is th e pr esen t a tio n   la y er I h and les  th e la n gu ag o f o rma th a t am  I  u sing ?   And  so when  I 'm   t al k i ng   ab out  th e c omm uni c a t i on t ha t 's  g oin acr oss  a p arti cula r   se ssion,  acr oss  a parti cular  pr ot oc ol,  I  c ould use m ul ti pl la ngu ag es .   If  I  use HT TP  an P or t   8 0   t he la ng ua g mig h t   be  HTML .  Or   I   c oul use  oth er   f or ma t s.  I  c oul d use  XML .   Th er e' a l ot of   oth er   l an gu age t ha t   mig h t   be  used acr oss  HT TP .   Al so som sour ce clai m th a SSL  lea v es  her e,   in   pr es en t a ti on  la y er .
7   la y er  OSI  model : 9. Whe w mo v up h er t o th se v en th   la y er  her e,   w e' r g onna t al k  about   th App li c a tion L a y er .  The A ppl ic a ti on  La y er   is  th actua ap pl i c a t i on  t ha t 's  g oin t mana g t he da t an d c on v er t i n f or ma t i on t da t an ba ck w ar ds.   Whe I  sa y A pp li ca tio La y er o u e x ample her w o u ld  b e br o w ser s,  a t lea s f o th c ase w e'r t al ki n about  HT TP .   Or  HT TP   c li en f o A PI .
C LI E N T SE R V I C E 7 A P P L I C A T I O N 6 P R E S E N T A T I O N 5 S E S S I ON 4 T R A N S P OR T 3 N E T W OR K D A T A LINK 1 P H Y S I C A L A P I   t e s t a u t o m a t i o n GET http://w ww . exa m pl e. com /c ust om ers /33 2 45 200  O P a y l o a d R e q u e s t d a t a     D a t a f o r ma t :80/ :443 UD P / T C P    IP M A C 10
Th OSI  model  descr i bes  ho t o   encap sulat the pie c es  o da t a  a nd   send   tr o u gh   th n e tw o rk .  W ell her e' a  pa ck e t   of  dat a .   T he b l ue  c olu mn. Ag ai n,  t hi i b e x ampl e,  I   am not   t r ying   t descr i be  pr ec i sely  s t anda r ds  of an I pack e ts  c on t en t, bec ause  th is  if   f ar  fr om   th is  w or k shop  sc ope.  I  am  g onna s t art h er a t   l a y er   se v en,  t he  Appl i c a t i on  La y er .   Her i t he  pa ck e t t he fi r s t   t hi ng   w e' r g onna do  i l a y er   se v en' g onna put   da t i her e,   som pa yload.   Th is d a t a c ould   b e en cr yp t ed .   I   c ould put  a fl ag   t ha t   sa y t ha t   encryp t i on  i s used.   A an  e x ample V PN Th e ne x t  la y er   of  t he mo del  i s six   an t hi i s wher I   w oul put   t he  f or ma t .  I  need  a w a y t o id en t i f wha t   t he  f or ma t   of  t he da t i s . I  ha v e la y er  fi v e and l a y er   f i v i s ab out  m y por t   or   m y pr ot oc ol.   I n her e,   I 'm  id en t i f ying w ha t   me chani sm I'm  usi ng .   I 'v g ot P or t   8 0 i f   i t 's  HT TP   f or   e x ampl e. 
My la y er   f our  her i s th e T r an sport  La y er .   Th t w mos t  c omm on  f or ms  of  t r an sport ar UDP User  Da t agr am Pr o t o c o a nd   T CP T r ansmissio n   Con tr o Pr o t o c o l . I UDP  sequence   of  deli v ery , se quence  of  t r an smissi on doesn't  me an   as  much. Th e other   op t i on  her i s T CP , T r an smissi on Con t r ol  Pr ot oc ol. Whe I   send  c on t en t  via   T CP sequ ence   ma t t er s. T CP  i s mo r i mpor t an t  th a t   i t   be  deli v er ed an d r eassem bl ed  sequen t i al l y .   Le t's  jus t sa I   ha v 2 0 - w or message. And  I  r ece iv pa rt  one,  pa rt  t w o pa r t   t hr ee , pa r t  fi v e. W ai t   I  need  pa r t  f our , R e t r a ns mit   pa rt  f ou so  t ha t   I   c an  r eassem bl e t he  me ssage . I f   I 'm  doi ng  U DP i t   mig h t   not  bee  needed. So  i n l a y er   f our  I  ha v e in f or ma t i on t ha t   al l o w s me   t r ec o v er   t he  c on t en t of  mult i pl pa ck e t s.  I  don't send  al l   of m da t i one  pa ck e t . chop  i t   i n t pi ec es
Th e bot t om  t hr ee   ne t w or k   l a y er s.  La y er   t w i wher t he  MA C ad dr ess  e x i s t s.   Th i i s th e ph y si c al   I D of  a ne t w or k   c ar i P cso I  wil l   ha v e the  FR OM  an d T O MA C ad dr esse s . And f i na l l l a y er   3   i f or   I ad dr ess.  Th i i t he  v ery  l as t   pi ec of  da t ad ded t o pack e t   an no w I  c an  send t hi pa ck e t   usi ng   t he  OSI model  ba ck  an d f or t be t w ee t he  t w de vices.  Th OSI   mod el is an  idealiz ed   ab s tr ac mod el,  and   th er e ar e n p r o t o c o ls  in u se  t o d a y th a t f o ll o it .   HT TP   w as cr ea t ed  wit hout  r eg ar t t he OSI  mode l so  t her e' no  poi n t  t o tr ying  t o m ak i t   ab solu t ely fi t .   I t   jus t  shoul d hel t i magi ne  wha t 's  g oin g on wh en  y ou  send  r eques t   som e whe r e.
R e q u e s t   - r e sp o n se   s t r uc t ur and typ e s 14 P O S T   /maps/ api/pla c e/ a dd /j s o n H T T P / 1 . 1 H o s t :   map s. g oog l ea pis . c om     C o n t e n t - T y p e :   appli c a ti on/ j s on    Acc ep t: app l i c a ti on /j s on { " l o c a t i o n " : { "l a t" : - 33.86 697 10, "l ng ": 151.1958750 }, "name":  "Andr e w a s her e", "phon e_ nu mbe r" : “+ 375( 29) 37 048 58", "types ":  ["bar"], } R e q u e s t   l i ne : ME TH OD |UR I |H T T P     v e r s i o n H E A D E R S M E S S A G E BO D Y
So  I  wil l   g o ahead  an mo v clot he  t mai t heme   of  t hi w or k shop.   I mos t   c ases when  y ou  ar w or k i ng   wit API it  means  th a t y o u   wil send   some r equ es and   c h ec some r espons e .   Th i i s ho i t   usua l l w or k s. So  th is  is  r eque s e x ample.  I t c onsis ts f r om   r eque s li ne,   header and  me ssage   body .  Message   body  i op t i onal .   F or   Ge t   i t   op t i onal , and H E AD  r eques t   shoul not   ha v e thi pa r t .   Ok r equ es li n c on t ai ns  R equ es t me th o d URI  o f r eso u r c e an v er sio n   o f p r o t o c o l .   Header  sec t i on  c on t ai ns a l l   i n f or ma t i on ab out   r eque s it se lf .   The o nl one   header   th a should  be  pr es en t ed  in   an c ase  i hos t .  Thi i ad dr ess  of  serv er   t ha t   w ar t al k i ng   t o. C ook i es,   c on t en t  types,  session  i n f or ma t i on wil l   be  s t or ed  i t hi sec t i on.   And r eques t   body  i t self .   Th i pa r t  c on t ai ns  t he  da t a,  t ha t   shoul d be sen t   t th se r v er .
R e q u e s t   - r e sp o n se   s t r uc t ur and typ e s 16 H T T P / 1 . 1   200 OK C o n t e n t - T y p e :   app l i c a ti on/ j s on; C o n t e n t - L e n g t h : 352 { "i d"  : "50ea6150666e0de 4b097", "plac e_ i d"  " qgY v C i 0 j l h Z T g z N G I " ,     "sc ope : "AP P ", " s t a t u s "   : "OK" } S t a t u s - L i n e : H T T P - V e r s i o n | S t a t u s - C o d e | R e a s o n - P h r a s e H E ADE R S M E S S A G E B O D Y
On  each r eques t   serv er   r epli es  wit h r esponse.  T ypic al l r espons wil c o n t ai n   St a tu s li n e, h ea d er and   messag e body St a tu s li ne  sho w e x ec ut ion s t a tu of  r eque s t.   Ar th er an er r or s,  or   r eques t   pr oce ssed  succe ss f ul l y .   Th er ar pr e t t bi amoun t  of  s t a t us  c odes,   I ’ll   descr i be  t hem  be t t er   i n ne x t  sli de.   Header pa r t  is t he same  wit h r eques t .   I t   c on t ai ns  i n f or ma t i on  ab out   r es ponse se ssion  da t a,  c ook ies,  and  siz of  m es sag body . And a  me ssage  body  i t self .   I t   c oul d be  J SON,  XML HTM L , m i me   t ypes.. .
R e q u e s t   - r e sp o n se   s t r uc t ur and typ e s 18 W E B S E R V I C E 2xx: Suc ces s 200 OK 201 C r e a t e d 4x x:  C l i e n t E r r o r 400  Bad R e q u e s t 403 F orbi d d e n 404 Not F ou n d 405  Me thod   No t Allow e d 410 Go n e 5x x:  Ser v er E r r o r 500  I n t e r n a l   Se r v e r E r r o r
About  s t a t us  c odes.  Th e ar r epr ese n t ed  an descr i bed  i RF 7 2 3 1 .   V al u o s t a tu s c o d r epr esen r esult of  r espons e x ec u tio n .  Ther ar fi v subgr oup s. One  hundr ed  t fi v hundr ed . Th mos t   c omm on  ar tw o h u n d r ed serv er   shoul d r e t urn  t hi c ode  i c ase  of su cc ess f ul  r eques t   pr oce ssi ng .   F our h u n d r ed s t a tu c ode should be r e tu r ned  in  c ase if   som e th in w en t   wr ong   on  r eques t or si de . And t he  500 (In t er na l   Serv er   Err or s t a t us  c ode  i ndi c a t es  t ha t   t he serv er   enc oun t er ed  an  une xpect ed c ondit ion t ha pr e v en t ed  it   fr om   fu lf il l i ng   t he r eques t .
D EL E TE R E A D    U P D A TE C R E A TE 201  C r e a t e d   + L o c a t i o n P O S T   http://w ww .ex am pl e.c om /cu st om ers  + pa ylo ad GET http://w ww . exa m pl e. com /c ust om ers /33 2 45 200  Ok  + P a y l o a d PUT http://w ww . exa m pl e.co m / cus tom ers /3 32 45 200 Ok D EL ET E http://w ww . exa m pl e.co m / cus tom ers /3 32 45 200 Ok RES and C R U D h t t p : / / www . a w e s o me por t a l . c o m :12 3 4 / p a t h / v er s i o n /r e so ur ce ? f oo= f oo%2 0 b a r     p r o t o c o l a d d r e s s port r e s o u r ce p a t h quer y 20
A n d   a f e w o r d about  RES T : 1. RE S is a r c h it ec tu r al   s tyle  o b u il d ing  w eb  ser vic es .  R es t   servi ce   usual ly  r epr es en ts  al da t as r es our ce s,  and  t in t er act wit th is  r esour ce w use  HT TP   me t hods.   So  t o send  r eques t   t i n t er act   wit h some   da t a,  r eques t   wil l   l ook l i k e:  t ype  of p r ot oc ol,  t hen wil l   be  t he hos t or   ad dr ess,   or   ma ybe  y ou  wil l   w on t   t o use  I an port.   Th ne x t  pa r t   i r esour ce   pa t h,  an her c oul d be v er si on  of  endpoin t .   And  la s part i s query it   c on t ai ns par ame t er th a y ou  w an t   t send t r esour ce .   2. E ach r esour ce   c oul d be  c r ea t ed r ea d u p d a t ed or   d ele t ed W ell   it  ob viousl depends  on  acce ss  an wha t  log i i s impl em en t ed  i n w eb  se r vice B ut   in   g ene r al : t hi is c al led  cru d ope r a ti ons.  The  m ai i dea  i s th a t   d a t sh o u ld  b e c r ea t ed  with  p o s me th o d r ea d   with  GET  me th o d t o  DELETE  d a t a, me th o d   DELETE   sh o u ld  b u sed an t u p d a t e,  me th o d   u p d a t sh o u ld  b u sed .
Cli e n s er v i ce inte r a c tion